devices/forcedeth-2.6.19-ethercat.c
author Florian Pose <fp@igh-essen.com>
Mon, 01 Sep 2008 14:21:42 +0000
changeset 1211 a7e939cd1416
parent 1011 a0759d0dded4
permissions -rw-r--r--
Removed branch information.
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 * forcedeth: Ethernet driver for NVIDIA nForce media access controllers.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 * Note: This driver is a cleanroom reimplementation based on reverse
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *      engineered documentation written by Carl-Daniel Hailfinger
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *      and Andrew de Quincey. It's neither supported nor endorsed
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *      by NVIDIA Corp. Use at your own risk.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 * NVIDIA, nForce and other NVIDIA marks are trademarks or registered
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 * trademarks of NVIDIA Corporation in the United States and other
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 * countries.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 * Copyright (C) 2003,4,5 Manfred Spraul
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 * Copyright (C) 2004 Andrew de Quincey (wol support)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *		IRQ rate fixes, bigendian fixes, cleanups, verification)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 * Copyright (c) 2004 NVIDIA Corporation
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 * This program is free software; you can redistribute it and/or modify
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 * it under the terms of the GNU General Public License as published by
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 * the Free Software Foundation; either version 2 of the License, or
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 * (at your option) any later version.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 * This program is distributed in the hope that it will be useful,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 * GNU General Public License for more details.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 * You should have received a copy of the GNU General Public License
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 * along with this program; if not, write to the Free Software
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
 * Changelog:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
 * 	0.01: 05 Oct 2003: First release that compiles without warnings.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
 * 	0.02: 05 Oct 2003: Fix bug for nv_drain_tx: do not try to free NULL skbs.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
 * 			   Check all PCI BARs for the register window.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
 * 			   udelay added to mii_rw.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
 * 	0.03: 06 Oct 2003: Initialize dev->irq.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
 * 	0.04: 07 Oct 2003: Initialize np->lock, reduce handled irqs, add printks.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
 * 	0.05: 09 Oct 2003: printk removed again, irq status print tx_timeout.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
 * 	0.06: 10 Oct 2003: MAC Address read updated, pff flag generation updated,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
 * 			   irq mask updated
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
 * 	0.07: 14 Oct 2003: Further irq mask updates.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
 * 	0.08: 20 Oct 2003: rx_desc.Length initialization added, nv_alloc_rx refill
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
 * 			   added into irq handler, NULL check for drain_ring.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 * 	0.09: 20 Oct 2003: Basic link speed irq implementation. Only handle the
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
 * 			   requested interrupt sources.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
 * 	0.10: 20 Oct 2003: First cleanup for release.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
 * 	0.11: 21 Oct 2003: hexdump for tx added, rx buffer sizes increased.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
 * 			   MAC Address init fix, set_multicast cleanup.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
 * 	0.12: 23 Oct 2003: Cleanups for release.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
 * 	0.13: 25 Oct 2003: Limit for concurrent tx packets increased to 10.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
 * 			   Set link speed correctly. start rx before starting
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
 * 			   tx (nv_start_rx sets the link speed).
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
 * 	0.14: 25 Oct 2003: Nic dependant irq mask.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
 * 	0.15: 08 Nov 2003: fix smp deadlock with set_multicast_list during
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
 * 			   open.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
 * 	0.16: 15 Nov 2003: include file cleanup for ppc64, rx buffer size
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
 * 			   increased to 1628 bytes.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
 * 	0.17: 16 Nov 2003: undo rx buffer size increase. Substract 1 from
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
 * 			   the tx length.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
 * 	0.18: 17 Nov 2003: fix oops due to late initialization of dev_stats
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
 * 	0.19: 29 Nov 2003: Handle RxNoBuf, detect & handle invalid mac
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
 * 			   addresses, really stop rx if already running
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
 * 			   in nv_start_rx, clean up a bit.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
 * 	0.20: 07 Dec 2003: alloc fixes
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
 * 	0.21: 12 Jan 2004: additional alloc fix, nic polling fix.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
 *	0.22: 19 Jan 2004: reprogram timer to a sane rate, avoid lockup
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
 *			   on close.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
 *	0.23: 26 Jan 2004: various small cleanups
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
 *	0.24: 27 Feb 2004: make driver even less anonymous in backtraces
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
 *	0.25: 09 Mar 2004: wol support
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
 *	0.26: 03 Jun 2004: netdriver specific annotation, sparse-related fixes
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
 *	0.27: 19 Jun 2004: Gigabit support, new descriptor rings,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
 *			   added CK804/MCP04 device IDs, code fixes
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
 *			   for registers, link status and other minor fixes.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
 *	0.28: 21 Jun 2004: Big cleanup, making driver mostly endian safe
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
 *	0.29: 31 Aug 2004: Add backup timer for link change notification.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
 *	0.30: 25 Sep 2004: rx checksum support for nf 250 Gb. Add rx reset
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
 *			   into nv_close, otherwise reenabling for wol can
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
 *			   cause DMA to kfree'd memory.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
 *	0.31: 14 Nov 2004: ethtool support for getting/setting link
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
 *			   capabilities.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
 *	0.32: 16 Apr 2005: RX_ERROR4 handling added.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
 *	0.33: 16 May 2005: Support for MCP51 added.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
 *	0.34: 18 Jun 2005: Add DEV_NEED_LINKTIMER to all nForce nics.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
 *	0.35: 26 Jun 2005: Support for MCP55 added.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
 *	0.36: 28 Jun 2005: Add jumbo frame support.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
 *	0.37: 10 Jul 2005: Additional ethtool support, cleanup of pci id list
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
 *	0.38: 16 Jul 2005: tx irq rewrite: Use global flags instead of
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
 *			   per-packet flags.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
 *	0.39: 18 Jul 2005: Add 64bit descriptor support.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
 *	0.40: 19 Jul 2005: Add support for mac address change.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
 *	0.41: 30 Jul 2005: Write back original MAC in nv_close instead
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
 *			   of nv_remove
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
 *	0.42: 06 Aug 2005: Fix lack of link speed initialization
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
 *			   in the second (and later) nv_open call
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
 *	0.43: 10 Aug 2005: Add support for tx checksum.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
 *	0.44: 20 Aug 2005: Add support for scatter gather and segmentation.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
 *	0.45: 18 Sep 2005: Remove nv_stop/start_rx from every link check
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
 *	0.46: 20 Oct 2005: Add irq optimization modes.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
 *	0.47: 26 Oct 2005: Add phyaddr 0 in phy scan.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
 *	0.48: 24 Dec 2005: Disable TSO, bugfix for pci_map_single
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
 *	0.49: 10 Dec 2005: Fix tso for large buffers.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
 *	0.50: 20 Jan 2006: Add 8021pq tagging support.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
 *	0.51: 20 Jan 2006: Add 64bit consistent memory allocation for rings.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
 *	0.52: 20 Jan 2006: Add MSI/MSIX support.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
 *	0.53: 19 Mar 2006: Fix init from low power mode and add hw reset.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
 *	0.54: 21 Mar 2006: Fix spin locks for multi irqs and cleanup.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
 *	0.55: 22 Mar 2006: Add flow control (pause frame).
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
 *	0.56: 22 Mar 2006: Additional ethtool config and moduleparam support.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
 *	0.57: 14 May 2006: Mac address set in probe/remove and order corrections.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
 * Known bugs:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
 * We suspect that on some hardware no TX done interrupts are generated.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
 * This means recovery from netif_stop_queue only happens if the hw timer
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
 * interrupt fires (100 times/second, configurable with NVREG_POLL_DEFAULT)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
 * and the timer is active in the IRQMask, or if a rx packet arrives by chance.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
 * If your hardware reliably generates tx done interrupts, then you can remove
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
 * DEV_NEED_TIMERIRQ from the driver_data flags.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
 * superfluous timer interrupts from the nic.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
#ifdef CONFIG_FORCEDETH_NAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
#define DRIVERNAPI "-NAPI"
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
#else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
#define DRIVERNAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
#define FORCEDETH_VERSION		"0.57"
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
#define DRV_NAME			"forcedeth"
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
#include <linux/module.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
#include <linux/types.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
#include <linux/pci.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
#include <linux/interrupt.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
#include <linux/netdevice.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
#include <linux/etherdevice.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
#include <linux/delay.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
#include <linux/spinlock.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
#include <linux/ethtool.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
#include <linux/timer.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
#include <linux/skbuff.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
#include <linux/mii.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
#include <linux/random.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
#include <linux/init.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
#include <linux/if_vlan.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
#include <linux/dma-mapping.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
#include <asm/irq.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
#include <asm/io.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
#include <asm/uaccess.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
#include <asm/system.h>
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
#include "../globals.h"
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
#include "ecdev.h"
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
#if 0
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
#define dprintk			printk
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
#else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
#define dprintk(x...)		do { } while (0)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
 * Hardware access:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
#define DEV_NEED_TIMERIRQ	0x0001  /* set the timer irq flag in the irq mask */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
#define DEV_NEED_LINKTIMER	0x0002	/* poll link settings. Relies on the timer irq */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
#define DEV_HAS_LARGEDESC	0x0004	/* device supports jumbo frames and needs packet format 2 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
#define DEV_HAS_HIGH_DMA        0x0008  /* device supports 64bit dma */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
#define DEV_HAS_CHECKSUM        0x0010  /* device supports tx and rx checksum offloads */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
#define DEV_HAS_VLAN            0x0020  /* device supports vlan tagging and striping */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
#define DEV_HAS_MSI             0x0040  /* device supports MSI */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
#define DEV_HAS_MSI_X           0x0080  /* device supports MSI-X */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
#define DEV_HAS_POWER_CNTRL     0x0100  /* device supports power savings */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
#define DEV_HAS_PAUSEFRAME_TX   0x0200  /* device supports tx pause frames */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
#define DEV_HAS_STATISTICS      0x0400  /* device supports hw statistics */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
#define DEV_HAS_TEST_EXTENDED   0x0800  /* device supports extended diagnostic test */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
enum {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
	NvRegIrqStatus = 0x000,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
#define NVREG_IRQSTAT_MIIEVENT	0x040
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
#define NVREG_IRQSTAT_MASK		0x1ff
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
	NvRegIrqMask = 0x004,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
#define NVREG_IRQ_RX_ERROR		0x0001
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
#define NVREG_IRQ_RX			0x0002
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
#define NVREG_IRQ_RX_NOBUF		0x0004
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
#define NVREG_IRQ_TX_ERR		0x0008
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
#define NVREG_IRQ_TX_OK			0x0010
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
#define NVREG_IRQ_TIMER			0x0020
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
#define NVREG_IRQ_LINK			0x0040
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
#define NVREG_IRQ_RX_FORCED		0x0080
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
#define NVREG_IRQ_TX_FORCED		0x0100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
#define NVREG_IRQMASK_THROUGHPUT	0x00df
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
#define NVREG_IRQMASK_CPU		0x0040
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
#define NVREG_IRQ_TX_ALL		(NVREG_IRQ_TX_ERR|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_FORCED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
#define NVREG_IRQ_RX_ALL		(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_RX_FORCED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
#define NVREG_IRQ_OTHER			(NVREG_IRQ_TIMER|NVREG_IRQ_LINK)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
#define NVREG_IRQ_UNKNOWN	(~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
					NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RX_FORCED| \
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
					NVREG_IRQ_TX_FORCED))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
	NvRegUnknownSetupReg6 = 0x008,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
#define NVREG_UNKSETUP6_VAL		3
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
 * NVREG_POLL_DEFAULT is the interval length of the timer source on the nic
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
 * NVREG_POLL_DEFAULT=97 would result in an interval length of 1 ms
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	NvRegPollingInterval = 0x00c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
#define NVREG_POLL_DEFAULT_THROUGHPUT	970
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
#define NVREG_POLL_DEFAULT_CPU	13
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
	NvRegMSIMap0 = 0x020,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
	NvRegMSIMap1 = 0x024,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
	NvRegMSIIrqMask = 0x030,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
#define NVREG_MSI_VECTOR_0_ENABLED 0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
	NvRegMisc1 = 0x080,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
#define NVREG_MISC1_PAUSE_TX	0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
#define NVREG_MISC1_HD		0x02
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
#define NVREG_MISC1_FORCE	0x3b0f3c
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
	NvRegMacReset = 0x3c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
#define NVREG_MAC_RESET_ASSERT	0x0F3
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
	NvRegTransmitterControl = 0x084,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
#define NVREG_XMITCTL_START	0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
	NvRegTransmitterStatus = 0x088,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
#define NVREG_XMITSTAT_BUSY	0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
	NvRegPacketFilterFlags = 0x8c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
#define NVREG_PFF_PAUSE_RX	0x08
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
#define NVREG_PFF_ALWAYS	0x7F0000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
#define NVREG_PFF_PROMISC	0x80
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
#define NVREG_PFF_MYADDR	0x20
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
#define NVREG_PFF_LOOPBACK	0x10
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
	NvRegOffloadConfig = 0x90,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
#define NVREG_OFFLOAD_HOMEPHY	0x601
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
#define NVREG_OFFLOAD_NORMAL	RX_NIC_BUFSIZE
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
	NvRegReceiverControl = 0x094,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
#define NVREG_RCVCTL_START	0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	NvRegReceiverStatus = 0x98,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
#define NVREG_RCVSTAT_BUSY	0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
	NvRegRandomSeed = 0x9c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
#define NVREG_RNDSEED_MASK	0x00ff
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
#define NVREG_RNDSEED_FORCE	0x7f00
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
#define NVREG_RNDSEED_FORCE2	0x2d00
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
#define NVREG_RNDSEED_FORCE3	0x7400
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	NvRegTxDeferral = 0xA0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
#define NVREG_TX_DEFERRAL_DEFAULT	0x15050f
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
#define NVREG_TX_DEFERRAL_RGMII_10_100	0x16070f
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
#define NVREG_TX_DEFERRAL_RGMII_1000	0x14050f
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
	NvRegRxDeferral = 0xA4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
#define NVREG_RX_DEFERRAL_DEFAULT	0x16
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
	NvRegMacAddrA = 0xA8,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
	NvRegMacAddrB = 0xAC,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
	NvRegMulticastAddrA = 0xB0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
#define NVREG_MCASTADDRA_FORCE	0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
	NvRegMulticastAddrB = 0xB4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
	NvRegMulticastMaskA = 0xB8,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
	NvRegMulticastMaskB = 0xBC,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
	NvRegPhyInterface = 0xC0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
#define PHY_RGMII		0x10000000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
	NvRegTxRingPhysAddr = 0x100,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
	NvRegRxRingPhysAddr = 0x104,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
	NvRegRingSizes = 0x108,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
#define NVREG_RINGSZ_TXSHIFT 0
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
#define NVREG_RINGSZ_RXSHIFT 16
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
	NvRegTransmitPoll = 0x10c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
#define NVREG_TRANSMITPOLL_MAC_ADDR_REV	0x00008000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
	NvRegLinkSpeed = 0x110,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
#define NVREG_LINKSPEED_FORCE 0x10000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
#define NVREG_LINKSPEED_10	1000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
#define NVREG_LINKSPEED_100	100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
#define NVREG_LINKSPEED_1000	50
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
#define NVREG_LINKSPEED_MASK	(0xFFF)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	NvRegUnknownSetupReg5 = 0x130,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
#define NVREG_UNKSETUP5_BIT31	(1<<31)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
	NvRegTxWatermark = 0x13c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
#define NVREG_TX_WM_DESC1_DEFAULT	0x0200010
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
#define NVREG_TX_WM_DESC2_3_DEFAULT	0x1e08000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
#define NVREG_TX_WM_DESC2_3_1000	0xfe08000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
	NvRegTxRxControl = 0x144,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
#define NVREG_TXRXCTL_KICK	0x0001
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
#define NVREG_TXRXCTL_BIT1	0x0002
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
#define NVREG_TXRXCTL_BIT2	0x0004
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
#define NVREG_TXRXCTL_IDLE	0x0008
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
#define NVREG_TXRXCTL_RESET	0x0010
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
#define NVREG_TXRXCTL_RXCHECK	0x0400
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
#define NVREG_TXRXCTL_DESC_1	0
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
#define NVREG_TXRXCTL_DESC_2	0x02100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
#define NVREG_TXRXCTL_DESC_3	0x02200
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
#define NVREG_TXRXCTL_VLANSTRIP 0x00040
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
#define NVREG_TXRXCTL_VLANINS	0x00080
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
	NvRegTxRingPhysAddrHigh = 0x148,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
	NvRegRxRingPhysAddrHigh = 0x14C,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	NvRegTxPauseFrame = 0x170,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
#define NVREG_TX_PAUSEFRAME_DISABLE	0x1ff0080
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
#define NVREG_TX_PAUSEFRAME_ENABLE	0x0c00030
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
	NvRegMIIStatus = 0x180,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
#define NVREG_MIISTAT_ERROR		0x0001
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
#define NVREG_MIISTAT_LINKCHANGE	0x0008
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
#define NVREG_MIISTAT_MASK		0x000f
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
#define NVREG_MIISTAT_MASK2		0x000f
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
	NvRegUnknownSetupReg4 = 0x184,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
#define NVREG_UNKSETUP4_VAL	8
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
	NvRegAdapterControl = 0x188,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
#define NVREG_ADAPTCTL_START	0x02
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
#define NVREG_ADAPTCTL_LINKUP	0x04
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
#define NVREG_ADAPTCTL_PHYVALID	0x40000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
#define NVREG_ADAPTCTL_RUNNING	0x100000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
#define NVREG_ADAPTCTL_PHYSHIFT	24
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	NvRegMIISpeed = 0x18c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
#define NVREG_MIISPEED_BIT8	(1<<8)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
#define NVREG_MIIDELAY	5
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
	NvRegMIIControl = 0x190,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
#define NVREG_MIICTL_INUSE	0x08000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
#define NVREG_MIICTL_WRITE	0x00400
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
#define NVREG_MIICTL_ADDRSHIFT	5
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
	NvRegMIIData = 0x194,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	NvRegWakeUpFlags = 0x200,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
#define NVREG_WAKEUPFLAGS_VAL		0x7770
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
#define NVREG_WAKEUPFLAGS_BUSYSHIFT	24
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
#define NVREG_WAKEUPFLAGS_ENABLESHIFT	16
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
#define NVREG_WAKEUPFLAGS_D3SHIFT	12
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
#define NVREG_WAKEUPFLAGS_D2SHIFT	8
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
#define NVREG_WAKEUPFLAGS_D1SHIFT	4
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
#define NVREG_WAKEUPFLAGS_D0SHIFT	0
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
#define NVREG_WAKEUPFLAGS_ACCEPT_MAGPAT		0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
#define NVREG_WAKEUPFLAGS_ACCEPT_WAKEUPPAT	0x02
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
#define NVREG_WAKEUPFLAGS_ACCEPT_LINKCHANGE	0x04
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
#define NVREG_WAKEUPFLAGS_ENABLE	0x1111
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
	NvRegPatternCRC = 0x204,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	NvRegPatternMask = 0x208,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
	NvRegPowerCap = 0x268,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
#define NVREG_POWERCAP_D3SUPP	(1<<30)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
#define NVREG_POWERCAP_D2SUPP	(1<<26)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
#define NVREG_POWERCAP_D1SUPP	(1<<25)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
	NvRegPowerState = 0x26c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
#define NVREG_POWERSTATE_POWEREDUP	0x8000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
#define NVREG_POWERSTATE_VALID		0x0100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
#define NVREG_POWERSTATE_MASK		0x0003
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
#define NVREG_POWERSTATE_D0		0x0000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
#define NVREG_POWERSTATE_D1		0x0001
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
#define NVREG_POWERSTATE_D2		0x0002
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
#define NVREG_POWERSTATE_D3		0x0003
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
	NvRegTxCnt = 0x280,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
	NvRegTxZeroReXmt = 0x284,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
	NvRegTxOneReXmt = 0x288,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
	NvRegTxManyReXmt = 0x28c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
	NvRegTxLateCol = 0x290,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
	NvRegTxUnderflow = 0x294,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
	NvRegTxLossCarrier = 0x298,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
	NvRegTxExcessDef = 0x29c,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
	NvRegTxRetryErr = 0x2a0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
	NvRegRxFrameErr = 0x2a4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
	NvRegRxExtraByte = 0x2a8,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
	NvRegRxLateCol = 0x2ac,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
	NvRegRxRunt = 0x2b0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
	NvRegRxFrameTooLong = 0x2b4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
	NvRegRxOverflow = 0x2b8,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
	NvRegRxFCSErr = 0x2bc,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
	NvRegRxFrameAlignErr = 0x2c0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
	NvRegRxLenErr = 0x2c4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
	NvRegRxUnicast = 0x2c8,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
	NvRegRxMulticast = 0x2cc,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	NvRegRxBroadcast = 0x2d0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
	NvRegTxDef = 0x2d4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
	NvRegTxFrame = 0x2d8,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
	NvRegRxCnt = 0x2dc,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
	NvRegTxPause = 0x2e0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
	NvRegRxPause = 0x2e4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	NvRegRxDropFrame = 0x2e8,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	NvRegVlanControl = 0x300,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
#define NVREG_VLANCONTROL_ENABLE	0x2000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
	NvRegMSIXMap0 = 0x3e0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
	NvRegMSIXMap1 = 0x3e4,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
	NvRegMSIXIrqStatus = 0x3f0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	NvRegPowerState2 = 0x600,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
#define NVREG_POWERSTATE2_POWERUP_MASK		0x0F11
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
#define NVREG_POWERSTATE2_POWERUP_REV_A3	0x0001
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
/* Big endian: should work, but is untested */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
struct ring_desc {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
	__le32 buf;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
	__le32 flaglen;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
struct ring_desc_ex {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
	__le32 bufhigh;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
	__le32 buflow;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
	__le32 txvlan;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
	__le32 flaglen;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
union ring_type {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
	struct ring_desc* orig;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
	struct ring_desc_ex* ex;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
#define FLAG_MASK_V1 0xffff0000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
#define FLAG_MASK_V2 0xffffc000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
#define LEN_MASK_V1 (0xffffffff ^ FLAG_MASK_V1)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
#define LEN_MASK_V2 (0xffffffff ^ FLAG_MASK_V2)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
#define NV_TX_LASTPACKET	(1<<16)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
#define NV_TX_RETRYERROR	(1<<19)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
#define NV_TX_FORCED_INTERRUPT	(1<<24)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
#define NV_TX_DEFERRED		(1<<26)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
#define NV_TX_CARRIERLOST	(1<<27)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
#define NV_TX_LATECOLLISION	(1<<28)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
#define NV_TX_UNDERFLOW		(1<<29)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
#define NV_TX_ERROR		(1<<30)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
#define NV_TX_VALID		(1<<31)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
#define NV_TX2_LASTPACKET	(1<<29)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
#define NV_TX2_RETRYERROR	(1<<18)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
#define NV_TX2_FORCED_INTERRUPT	(1<<30)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
#define NV_TX2_DEFERRED		(1<<25)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
#define NV_TX2_CARRIERLOST	(1<<26)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
#define NV_TX2_LATECOLLISION	(1<<27)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
#define NV_TX2_UNDERFLOW	(1<<28)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
/* error and valid are the same for both */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
#define NV_TX2_ERROR		(1<<30)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
#define NV_TX2_VALID		(1<<31)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
#define NV_TX2_TSO		(1<<28)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
#define NV_TX2_TSO_SHIFT	14
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
#define NV_TX2_TSO_MAX_SHIFT	14
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
#define NV_TX2_TSO_MAX_SIZE	(1<<NV_TX2_TSO_MAX_SHIFT)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
#define NV_TX2_CHECKSUM_L3	(1<<27)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
#define NV_TX2_CHECKSUM_L4	(1<<26)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
#define NV_TX3_VLAN_TAG_PRESENT (1<<18)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
#define NV_RX_DESCRIPTORVALID	(1<<16)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
#define NV_RX_MISSEDFRAME	(1<<17)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
#define NV_RX_SUBSTRACT1	(1<<18)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
#define NV_RX_ERROR1		(1<<23)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
#define NV_RX_ERROR2		(1<<24)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
#define NV_RX_ERROR3		(1<<25)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
#define NV_RX_ERROR4		(1<<26)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
#define NV_RX_CRCERR		(1<<27)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
#define NV_RX_OVERFLOW		(1<<28)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
#define NV_RX_FRAMINGERR	(1<<29)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
#define NV_RX_ERROR		(1<<30)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
#define NV_RX_AVAIL		(1<<31)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
#define NV_RX2_CHECKSUMMASK	(0x1C000000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
#define NV_RX2_CHECKSUMOK1	(0x10000000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
#define NV_RX2_CHECKSUMOK2	(0x14000000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
#define NV_RX2_CHECKSUMOK3	(0x18000000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
#define NV_RX2_DESCRIPTORVALID	(1<<29)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
#define NV_RX2_SUBSTRACT1	(1<<25)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
#define NV_RX2_ERROR1		(1<<18)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
#define NV_RX2_ERROR2		(1<<19)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
#define NV_RX2_ERROR3		(1<<20)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
#define NV_RX2_ERROR4		(1<<21)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
#define NV_RX2_CRCERR		(1<<22)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
#define NV_RX2_OVERFLOW		(1<<23)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
#define NV_RX2_FRAMINGERR	(1<<24)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
/* error and avail are the same for both */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
#define NV_RX2_ERROR		(1<<30)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
#define NV_RX2_AVAIL		(1<<31)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
#define NV_RX3_VLAN_TAG_PRESENT (1<<16)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
#define NV_RX3_VLAN_TAG_MASK	(0x0000FFFF)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
/* Miscelaneous hardware related defines: */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
#define NV_PCI_REGSZ_VER1      	0x270
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
#define NV_PCI_REGSZ_VER2      	0x604
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
/* various timeout delays: all in usec */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
#define NV_TXRX_RESET_DELAY	4
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
#define NV_TXSTOP_DELAY1	10
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
#define NV_TXSTOP_DELAY1MAX	500000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
#define NV_TXSTOP_DELAY2	100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
#define NV_RXSTOP_DELAY1	10
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
#define NV_RXSTOP_DELAY1MAX	500000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
#define NV_RXSTOP_DELAY2	100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
#define NV_SETUP5_DELAY		5
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
#define NV_SETUP5_DELAYMAX	50000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
#define NV_POWERUP_DELAY	5
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
#define NV_POWERUP_DELAYMAX	5000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
#define NV_MIIBUSY_DELAY	50
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
#define NV_MIIPHY_DELAY	10
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
#define NV_MIIPHY_DELAYMAX	10000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
#define NV_MAC_RESET_DELAY	64
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
#define NV_WAKEUPPATTERNS	5
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
#define NV_WAKEUPMASKENTRIES	4
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
/* General driver defaults */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
#define NV_WATCHDOG_TIMEO	(5*HZ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
#define RX_RING_DEFAULT		128
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
#define TX_RING_DEFAULT		256
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
#define RX_RING_MIN		128
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
#define TX_RING_MIN		64
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
#define RING_MAX_DESC_VER_1	1024
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
#define RING_MAX_DESC_VER_2_3	16384
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
 * Difference between the get and put pointers for the tx ring.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
 * This is used to throttle the amount of data outstanding in the
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
 * tx ring.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
#define TX_LIMIT_DIFFERENCE	1
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
/* rx/tx mac addr + type + vlan + align + slack*/
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
#define NV_RX_HEADERS		(64)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
/* even more slack. */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
#define NV_RX_ALLOC_PAD		(64)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
/* maximum mtu size */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
#define NV_PKTLIMIT_1	ETH_DATA_LEN	/* hard limit not known */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
#define NV_PKTLIMIT_2	9100	/* Actual limit according to NVidia: 9202 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
#define OOM_REFILL	(1+HZ/20)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
#define POLL_WAIT	(1+HZ/100)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
#define LINK_TIMEOUT	(3*HZ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
#define STATS_INTERVAL	(10*HZ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
 * desc_ver values:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
 * The nic supports three different descriptor types:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
 * - DESC_VER_1: Original
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
 * - DESC_VER_2: support for jumbo frames.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
 * - DESC_VER_3: 64-bit format.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
#define DESC_VER_1	1
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
#define DESC_VER_2	2
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
#define DESC_VER_3	3
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
/* PHY defines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
#define PHY_OUI_MARVELL	0x5043
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
#define PHY_OUI_CICADA	0x03f1
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
#define PHYID1_OUI_MASK	0x03ff
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
#define PHYID1_OUI_SHFT	6
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
#define PHYID2_OUI_MASK	0xfc00
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
#define PHYID2_OUI_SHFT	10
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
#define PHYID2_MODEL_MASK		0x03f0
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
#define PHY_MODEL_MARVELL_E3016		0x220
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
#define PHY_MARVELL_E3016_INITMASK	0x0300
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
#define PHY_INIT1	0x0f000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
#define PHY_INIT2	0x0e00
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
#define PHY_INIT3	0x01000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
#define PHY_INIT4	0x0200
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
#define PHY_INIT5	0x0004
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
#define PHY_INIT6	0x02000
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
#define PHY_GIGABIT	0x0100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
#define PHY_TIMEOUT	0x1
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
#define PHY_ERROR	0x2
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
#define PHY_100	0x1
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
#define PHY_1000	0x2
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
#define PHY_HALF	0x100
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
#define NV_PAUSEFRAME_RX_CAPABLE 0x0001
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
#define NV_PAUSEFRAME_TX_CAPABLE 0x0002
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
#define NV_PAUSEFRAME_RX_ENABLE  0x0004
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
#define NV_PAUSEFRAME_TX_ENABLE  0x0008
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
#define NV_PAUSEFRAME_RX_REQ     0x0010
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
#define NV_PAUSEFRAME_TX_REQ     0x0020
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
#define NV_PAUSEFRAME_AUTONEG    0x0040
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
/* MSI/MSI-X defines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
#define NV_MSI_X_MAX_VECTORS  8
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
#define NV_MSI_X_VECTORS_MASK 0x000f
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
#define NV_MSI_CAPABLE        0x0010
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
#define NV_MSI_X_CAPABLE      0x0020
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
#define NV_MSI_ENABLED        0x0040
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
#define NV_MSI_X_ENABLED      0x0080
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
#define NV_MSI_X_VECTOR_ALL   0x0
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
#define NV_MSI_X_VECTOR_RX    0x0
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
#define NV_MSI_X_VECTOR_TX    0x1
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
#define NV_MSI_X_VECTOR_OTHER 0x2
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
/* statistics */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
struct nv_ethtool_str {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
	char name[ETH_GSTRING_LEN];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
static const struct nv_ethtool_str nv_estats_str[] = {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
	{ "tx_bytes" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
	{ "tx_zero_rexmt" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
	{ "tx_one_rexmt" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
	{ "tx_many_rexmt" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
	{ "tx_late_collision" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
	{ "tx_fifo_errors" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
	{ "tx_carrier_errors" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
	{ "tx_excess_deferral" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
	{ "tx_retry_error" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
	{ "tx_deferral" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
	{ "tx_packets" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
	{ "tx_pause" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
	{ "rx_frame_error" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
	{ "rx_extra_byte" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
	{ "rx_late_collision" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
	{ "rx_runt" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
	{ "rx_frame_too_long" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
	{ "rx_over_errors" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	{ "rx_crc_errors" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
	{ "rx_frame_align_error" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
	{ "rx_length_error" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
	{ "rx_unicast" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
	{ "rx_multicast" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
	{ "rx_broadcast" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
	{ "rx_bytes" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
	{ "rx_pause" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
	{ "rx_drop_frame" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
	{ "rx_packets" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
	{ "rx_errors_total" }
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
struct nv_ethtool_stats {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	u64 tx_bytes;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
	u64 tx_zero_rexmt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
	u64 tx_one_rexmt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
	u64 tx_many_rexmt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
	u64 tx_late_collision;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
	u64 tx_fifo_errors;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
	u64 tx_carrier_errors;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
	u64 tx_excess_deferral;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
	u64 tx_retry_error;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
	u64 tx_deferral;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
	u64 tx_packets;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
	u64 tx_pause;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
	u64 rx_frame_error;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
	u64 rx_extra_byte;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
	u64 rx_late_collision;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
	u64 rx_runt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
	u64 rx_frame_too_long;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
	u64 rx_over_errors;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	u64 rx_crc_errors;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
	u64 rx_frame_align_error;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
	u64 rx_length_error;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
	u64 rx_unicast;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
	u64 rx_multicast;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
	u64 rx_broadcast;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
	u64 rx_bytes;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
	u64 rx_pause;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
	u64 rx_drop_frame;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
	u64 rx_packets;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
	u64 rx_errors_total;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
/* diagnostics */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
#define NV_TEST_COUNT_BASE 3
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
#define NV_TEST_COUNT_EXTENDED 4
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
static const struct nv_ethtool_str nv_etests_str[] = {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
	{ "link      (online/offline)" },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
	{ "register  (offline)       " },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
	{ "interrupt (offline)       " },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
	{ "loopback  (offline)       " }
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
struct register_test {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
	__le32 reg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
	__le32 mask;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
static const struct register_test nv_registers_test[] = {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	{ NvRegUnknownSetupReg6, 0x01 },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	{ NvRegMisc1, 0x03c },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	{ NvRegOffloadConfig, 0x03ff },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
	{ NvRegMulticastAddrA, 0xffffffff },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	{ NvRegTxWatermark, 0x0ff },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	{ NvRegWakeUpFlags, 0x07777 },
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	{ 0,0 }
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
 * SMP locking:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
 * All hardware access under dev->priv->lock, except the performance
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
 * critical parts:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
 * - rx is (pseudo-) lockless: it relies on the single-threading provided
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
 *	by the arch code for interrupts.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
 * - tx setup is lockless: it relies on netif_tx_lock. Actual submission
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
 *	needs dev->priv->lock :-(
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
 * - set_multicast_list: preparation lockless, relies on netif_tx_lock.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
/* in dev: base, irq */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
struct fe_priv {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
	spinlock_t lock;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
	/* General data:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
	 * Locking: spin_lock(&np->lock); */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	struct net_device_stats stats;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	struct nv_ethtool_stats estats;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
	int in_shutdown;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
	u32 linkspeed;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
	int duplex;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
	int autoneg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	int fixed_mode;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
	int phyaddr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	int wolenabled;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
	unsigned int phy_oui;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
	unsigned int phy_model;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	u16 gigabit;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
	int intr_test;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
	/* General data: RO fields */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
	dma_addr_t ring_addr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
	struct pci_dev *pci_dev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	u32 orig_mac[2];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
	u32 irqmask;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
	u32 desc_ver;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
	u32 txrxctl_bits;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
	u32 vlanctl_bits;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
	u32 driver_data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
	u32 register_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
	int rx_csum;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
	void __iomem *base;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
	/* rx specific fields.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
	 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
	union ring_type rx_ring;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
	unsigned int cur_rx, refill_rx;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
	struct sk_buff **rx_skbuff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
	dma_addr_t *rx_dma;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
	unsigned int rx_buf_sz;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
	unsigned int pkt_limit;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
	struct timer_list oom_kick;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
	struct timer_list nic_poll;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
	struct timer_list stats_poll;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	u32 nic_poll_irq;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	int rx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
	/* media detection workaround.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
	 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
	int need_linktimer;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
	unsigned long link_timeout;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
	/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
	 * tx specific fields.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
	union ring_type tx_ring;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
	unsigned int next_tx, nic_tx;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
	struct sk_buff **tx_skbuff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
	dma_addr_t *tx_dma;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
	unsigned int *tx_dma_len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
	u32 tx_flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
	int tx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
	int tx_limit_start;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
	int tx_limit_stop;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
	/* vlan fields */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
	struct vlan_group *vlangrp;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
	/* msi/msi-x fields */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
	u32 msi_flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	struct msix_entry msi_x_entry[NV_MSI_X_MAX_VECTORS];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
	/* flow control */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
	u32 pause_flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
    ec_device_t *ecdev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
 * Maximum number of loops until we assume that a bit in the irq mask
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
 * is stuck. Overridable with module param.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
static int max_interrupt_work = 5;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
 * Optimization can be either throuput mode or cpu mode
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
 * Throughput Mode: Every tx and rx packet will generate an interrupt.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
 * CPU Mode: Interrupts are controlled by a timer.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
enum {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
	NV_OPTIMIZATION_MODE_THROUGHPUT,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
	NV_OPTIMIZATION_MODE_CPU
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
static int optimization_mode = NV_OPTIMIZATION_MODE_THROUGHPUT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
 * Poll interval for timer irq
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
 * This interval determines how frequent an interrupt is generated.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
 * The is value is determined by [(time_in_micro_secs * 100) / (2^10)]
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
 * Min = 0, and Max = 65535
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
static int poll_interval = -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
 * MSI interrupts
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
enum {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
	NV_MSI_INT_DISABLED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
	NV_MSI_INT_ENABLED
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
static int msi = NV_MSI_INT_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
 * MSIX interrupts
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
enum {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	NV_MSIX_INT_DISABLED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
	NV_MSIX_INT_ENABLED
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
static int msix = NV_MSIX_INT_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
 * DMA 64bit
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
enum {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	NV_DMA_64BIT_DISABLED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
	NV_DMA_64BIT_ENABLED
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
static int dma_64bit = NV_DMA_64BIT_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
static int board_idx = -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
static inline struct fe_priv *get_nvpriv(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	return netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
static inline u8 __iomem *get_hwbase(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
	return ((struct fe_priv *)netdev_priv(dev))->base;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
static inline void pci_push(u8 __iomem *base)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
	/* force out pending posted writes */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	readl(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
static inline u32 nv_descr_getlength(struct ring_desc *prd, u32 v)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
	return le32_to_cpu(prd->flaglen)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
		& ((v == DESC_VER_1) ? LEN_MASK_V1 : LEN_MASK_V2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
static inline u32 nv_descr_getlength_ex(struct ring_desc_ex *prd, u32 v)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
	return le32_to_cpu(prd->flaglen) & LEN_MASK_V2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
static int reg_delay(struct net_device *dev, int offset, u32 mask, u32 target,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
				int delay, int delaymax, const char *msg)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
	do {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
		udelay(delay);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
		delaymax -= delay;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
		if (delaymax < 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
			if (msg)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
				printk(msg);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
			return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
	} while ((readl(base + offset) & mask) != target);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
#define NV_SETUP_RX_RING 0x01
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
#define NV_SETUP_TX_RING 0x02
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
static void setup_hw_rings(struct net_device *dev, int rxtx_flags)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
		if (rxtx_flags & NV_SETUP_RX_RING) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
			writel((u32) cpu_to_le64(np->ring_addr), base + NvRegRxRingPhysAddr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
		if (rxtx_flags & NV_SETUP_TX_RING) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
			writel((u32) cpu_to_le64(np->ring_addr + np->rx_ring_size*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
		if (rxtx_flags & NV_SETUP_RX_RING) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
			writel((u32) cpu_to_le64(np->ring_addr), base + NvRegRxRingPhysAddr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
			writel((u32) (cpu_to_le64(np->ring_addr) >> 32), base + NvRegRxRingPhysAddrHigh);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
		if (rxtx_flags & NV_SETUP_TX_RING) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
			writel((u32) cpu_to_le64(np->ring_addr + np->rx_ring_size*sizeof(struct ring_desc_ex)), base + NvRegTxRingPhysAddr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
			writel((u32) (cpu_to_le64(np->ring_addr + np->rx_ring_size*sizeof(struct ring_desc_ex)) >> 32), base + NvRegTxRingPhysAddrHigh);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
static void free_rings(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
		if (np->rx_ring.orig)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
			pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (np->rx_ring_size + np->tx_ring_size),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
					    np->rx_ring.orig, np->ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
		if (np->rx_ring.ex)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
			pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (np->rx_ring_size + np->tx_ring_size),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
					    np->rx_ring.ex, np->ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	if (np->rx_skbuff)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
		kfree(np->rx_skbuff);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
	if (np->rx_dma)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
		kfree(np->rx_dma);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
	if (np->tx_skbuff)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
		kfree(np->tx_skbuff);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
	if (np->tx_dma)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
		kfree(np->tx_dma);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	if (np->tx_dma_len)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
		kfree(np->tx_dma_len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
static int using_multi_irqs(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
	if (!(np->msi_flags & NV_MSI_X_ENABLED) ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
	    ((np->msi_flags & NV_MSI_X_ENABLED) &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
	     ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1)))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
		return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
static void nv_enable_irq(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
	if (!using_multi_irqs(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
		if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
			enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
			enable_irq(dev->irq);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
		enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
		enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
		enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
static void nv_disable_irq(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
	if (!using_multi_irqs(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
		if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
			disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
			disable_irq(dev->irq);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
		disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
		disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
		disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
/* In MSIX mode, a write to irqmask behaves as XOR */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
static void nv_enable_hw_interrupts(struct net_device *dev, u32 mask)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
	writel(mask, base + NvRegIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
static void nv_disable_hw_interrupts(struct net_device *dev, u32 mask)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
	if (np->msi_flags & NV_MSI_X_ENABLED) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
		writel(mask, base + NvRegIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
		if (np->msi_flags & NV_MSI_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
			writel(0, base + NvRegMSIIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
		writel(0, base + NvRegIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
#define MII_READ	(-1)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
/* mii_rw: read/write a register on the PHY.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
 * Caller must guarantee serialization
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
static int mii_rw(struct net_device *dev, int addr, int miireg, int value)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	u32 reg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
	int retval;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
	writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
	reg = readl(base + NvRegMIIControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
	if (reg & NVREG_MIICTL_INUSE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
		writel(NVREG_MIICTL_INUSE, base + NvRegMIIControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
		udelay(NV_MIIBUSY_DELAY);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	reg = (addr << NVREG_MIICTL_ADDRSHIFT) | miireg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
	if (value != MII_READ) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
		writel(value, base + NvRegMIIData);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
		reg |= NVREG_MIICTL_WRITE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
	writel(reg, base + NvRegMIIControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
	if (reg_delay(dev, NvRegMIIControl, NVREG_MIICTL_INUSE, 0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
			NV_MIIPHY_DELAY, NV_MIIPHY_DELAYMAX, NULL)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
		dprintk(KERN_DEBUG "%s: mii_rw of reg %d at PHY %d timed out.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
				dev->name, miireg, addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
		retval = -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	} else if (value != MII_READ) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
		/* it was a write operation - fewer failures are detectable */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
		dprintk(KERN_DEBUG "%s: mii_rw wrote 0x%x to reg %d at PHY %d\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
				dev->name, value, miireg, addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
		retval = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
	} else if (readl(base + NvRegMIIStatus) & NVREG_MIISTAT_ERROR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		dprintk(KERN_DEBUG "%s: mii_rw of reg %d at PHY %d failed.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
				dev->name, miireg, addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
		retval = -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
		retval = readl(base + NvRegMIIData);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
		dprintk(KERN_DEBUG "%s: mii_rw read from reg %d at PHY %d: 0x%x.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
				dev->name, miireg, addr, retval);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
	return retval;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
static int phy_reset(struct net_device *dev, u32 bmcr_setup)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	u32 miicontrol;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	unsigned int tries = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	miicontrol = BMCR_RESET | bmcr_setup;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
	if (mii_rw(dev, np->phyaddr, MII_BMCR, miicontrol)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
		return -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	/* wait for 500ms */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
	msleep(500);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
	/* must wait till reset is deasserted */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
	while (miicontrol & BMCR_RESET) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
		msleep(10);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
		miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
		/* FIXME: 100 tries seem excessive */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
		if (tries++ > 100)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
			return -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
static int phy_init(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	u32 phyinterface, phy_reserved, mii_status, mii_control, mii_control_1000,reg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
	/* phy errata for E3016 phy */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	if (np->phy_model == PHY_MODEL_MARVELL_E3016) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
		reg = mii_rw(dev, np->phyaddr, MII_NCONFIG, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
		reg &= ~PHY_MARVELL_E3016_INITMASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
		if (mii_rw(dev, np->phyaddr, MII_NCONFIG, reg)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
			printk(KERN_INFO "%s: phy write to errata reg failed.\n", pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
			return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	/* set advertise register */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
	reg = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	reg |= (ADVERTISE_10HALF|ADVERTISE_10FULL|ADVERTISE_100HALF|ADVERTISE_100FULL|ADVERTISE_PAUSE_ASYM|ADVERTISE_PAUSE_CAP);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	if (mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
		printk(KERN_INFO "%s: phy write to advertise failed.\n", pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
		return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
	/* get phy interface type */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
	phyinterface = readl(base + NvRegPhyInterface);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
	/* see if gigabit phy */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
	mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
	if (mii_status & PHY_GIGABIT) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
		np->gigabit = PHY_GIGABIT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
		mii_control_1000 = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
		mii_control_1000 &= ~ADVERTISE_1000HALF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
		if (phyinterface & PHY_RGMII)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
			mii_control_1000 |= ADVERTISE_1000FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
			mii_control_1000 &= ~ADVERTISE_1000FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
		if (mii_rw(dev, np->phyaddr, MII_CTRL1000, mii_control_1000)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
			printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
			return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
		np->gigabit = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
	mii_control = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
	mii_control |= BMCR_ANENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
	/* reset the phy
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	 * (certain phys need bmcr to be setup with reset)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
	if (phy_reset(dev, mii_control)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
		printk(KERN_INFO "%s: phy reset failed\n", pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
		return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
	/* phy vendor specific configuration */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
	if ((np->phy_oui == PHY_OUI_CICADA) && (phyinterface & PHY_RGMII) ) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
		phy_reserved = mii_rw(dev, np->phyaddr, MII_RESV1, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
		phy_reserved &= ~(PHY_INIT1 | PHY_INIT2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
		phy_reserved |= (PHY_INIT3 | PHY_INIT4);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
		if (mii_rw(dev, np->phyaddr, MII_RESV1, phy_reserved)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
			printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
			return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
		phy_reserved = mii_rw(dev, np->phyaddr, MII_NCONFIG, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
		phy_reserved |= PHY_INIT5;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
		if (mii_rw(dev, np->phyaddr, MII_NCONFIG, phy_reserved)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
			printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
			return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
	if (np->phy_oui == PHY_OUI_CICADA) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
		phy_reserved = mii_rw(dev, np->phyaddr, MII_SREVISION, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
		phy_reserved |= PHY_INIT6;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
		if (mii_rw(dev, np->phyaddr, MII_SREVISION, phy_reserved)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
			printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
			return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
	/* some phys clear out pause advertisment on reset, set it back */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
	/* restart auto negotiation */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
	mii_control = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
	mii_control |= (BMCR_ANRESTART | BMCR_ANENABLE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	if (mii_rw(dev, np->phyaddr, MII_BMCR, mii_control)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
		return PHY_ERROR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
static void nv_start_rx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
	dprintk(KERN_DEBUG "%s: nv_start_rx\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
	/* Already running? Stop it. */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
	if (readl(base + NvRegReceiverControl) & NVREG_RCVCTL_START) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		writel(0, base + NvRegReceiverControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
	writel(np->linkspeed, base + NvRegLinkSpeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	writel(NVREG_RCVCTL_START, base + NvRegReceiverControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	dprintk(KERN_DEBUG "%s: nv_start_rx to duplex %d, speed 0x%08x.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
				dev->name, np->duplex, np->linkspeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
static void nv_stop_rx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
	dprintk(KERN_DEBUG "%s: nv_stop_rx\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
	writel(0, base + NvRegReceiverControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
	reg_delay(dev, NvRegReceiverStatus, NVREG_RCVSTAT_BUSY, 0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
			NV_RXSTOP_DELAY1, NV_RXSTOP_DELAY1MAX,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
			KERN_INFO "nv_stop_rx: ReceiverStatus remained busy");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
	udelay(NV_RXSTOP_DELAY2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
	writel(0, base + NvRegLinkSpeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
static void nv_start_tx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
	dprintk(KERN_DEBUG "%s: nv_start_tx\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
	writel(NVREG_XMITCTL_START, base + NvRegTransmitterControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
static void nv_stop_tx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	dprintk(KERN_DEBUG "%s: nv_stop_tx\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
	writel(0, base + NvRegTransmitterControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	reg_delay(dev, NvRegTransmitterStatus, NVREG_XMITSTAT_BUSY, 0,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
			NV_TXSTOP_DELAY1, NV_TXSTOP_DELAY1MAX,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
			KERN_INFO "nv_stop_tx: TransmitterStatus remained busy");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
	udelay(NV_TXSTOP_DELAY2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
	writel(readl(base + NvRegTransmitPoll) & NVREG_TRANSMITPOLL_MAC_ADDR_REV, base + NvRegTransmitPoll);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
static void nv_txrx_reset(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
	dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
	writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->txrxctl_bits, base + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
	udelay(NV_TXRX_RESET_DELAY);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
	writel(NVREG_TXRXCTL_BIT2 | np->txrxctl_bits, base + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
static void nv_mac_reset(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
	dprintk(KERN_DEBUG "%s: nv_mac_reset\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
	writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->txrxctl_bits, base + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	writel(NVREG_MAC_RESET_ASSERT, base + NvRegMacReset);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	udelay(NV_MAC_RESET_DELAY);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
	writel(0, base + NvRegMacReset);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
	udelay(NV_MAC_RESET_DELAY);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	writel(NVREG_TXRXCTL_BIT2 | np->txrxctl_bits, base + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
 * nv_get_stats: dev->get_stats function
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
 * Get latest stats value from the nic.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
 * Called with read_lock(&dev_base_lock) held for read -
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
 * only synchronized against unregister_netdevice.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
static struct net_device_stats *nv_get_stats(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
	/* It seems that the nic always generates interrupts and doesn't
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
	 * accumulate errors internally. Thus the current values in np->stats
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
	 * are already up to date.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
	return &np->stats;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
 * nv_alloc_rx: fill rx ring entries.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
 * Return 1 if the allocations for the skbs failed and the
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
 * rx engine is without Available descriptors
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
static int nv_alloc_rx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
	unsigned int refill_rx = np->refill_rx;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
	int nr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
	while (np->cur_rx != refill_rx) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
		struct sk_buff *skb;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
		nr = refill_rx % np->rx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
		if (np->rx_skbuff[nr] == NULL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
			skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
			if (!skb)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
				break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
			skb->dev = dev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
			np->rx_skbuff[nr] = skb;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
			skb = np->rx_skbuff[nr];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
		np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
					skb->end-skb->data, PCI_DMA_FROMDEVICE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
			np->rx_ring.orig[nr].buf = cpu_to_le32(np->rx_dma[nr]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
			wmb();
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
			np->rx_ring.orig[nr].flaglen = cpu_to_le32(np->rx_buf_sz | NV_RX_AVAIL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
			np->rx_ring.ex[nr].bufhigh = cpu_to_le64(np->rx_dma[nr]) >> 32;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
			np->rx_ring.ex[nr].buflow = cpu_to_le64(np->rx_dma[nr]) & 0x0FFFFFFFF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
			wmb();
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
			np->rx_ring.ex[nr].flaglen = cpu_to_le32(np->rx_buf_sz | NV_RX2_AVAIL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
		dprintk(KERN_DEBUG "%s: nv_alloc_rx: Packet %d marked as Available\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
					dev->name, refill_rx);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
		refill_rx++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
	np->refill_rx = refill_rx;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
	if (np->cur_rx - refill_rx == np->rx_ring_size)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
		return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
/* If rx bufs are exhausted called after 50ms to attempt to refresh */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
#ifdef CONFIG_FORCEDETH_NAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
static void nv_do_rx_refill(unsigned long data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
	/* Just reschedule NAPI rx processing */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	netif_rx_schedule(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
#else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
static void nv_do_rx_refill(unsigned long data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
	if (!using_multi_irqs(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
		if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
			disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
			disable_irq(dev->irq);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
		disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
	if (nv_alloc_rx(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
		if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
			mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
		spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
	if (!using_multi_irqs(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
		if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
			enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
			enable_irq(dev->irq);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
		enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
static void nv_init_rx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
	np->cur_rx = np->rx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
	np->refill_rx = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
	for (i = 0; i < np->rx_ring_size; i++)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
			np->rx_ring.orig[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
	        else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
			np->rx_ring.ex[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
static void nv_init_tx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
	np->next_tx = np->nic_tx = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	for (i = 0; i < np->tx_ring_size; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
			np->tx_ring.orig[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	        else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
			np->tx_ring.ex[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
		np->tx_skbuff[i] = NULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
		np->tx_dma[i] = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
static int nv_init_ring(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	nv_init_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
	nv_init_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	return nv_alloc_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
static int nv_release_txskb(struct net_device *dev, unsigned int skbnr)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
	dprintk(KERN_INFO "%s: nv_release_txskb for skbnr %d\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
		dev->name, skbnr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	if (np->tx_dma[skbnr]) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
		pci_unmap_page(np->pci_dev, np->tx_dma[skbnr],
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
			       np->tx_dma_len[skbnr],
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
			       PCI_DMA_TODEVICE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
		np->tx_dma[skbnr] = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	if (np->tx_skbuff[skbnr]) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
		if (!np->ecdev) dev_kfree_skb_any(np->tx_skbuff[skbnr]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
		np->tx_skbuff[skbnr] = NULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
		return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
static void nv_drain_tx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
	unsigned int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
	for (i = 0; i < np->tx_ring_size; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
			np->tx_ring.orig[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
			np->tx_ring.ex[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
		if (nv_release_txskb(dev, i))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
			np->stats.tx_dropped++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
static void nv_drain_rx(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
	for (i = 0; i < np->rx_ring_size; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
			np->rx_ring.orig[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
			np->rx_ring.ex[i].flaglen = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
		wmb();
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
		if (np->rx_skbuff[i]) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
			pci_unmap_single(np->pci_dev, np->rx_dma[i],
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
						np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
						PCI_DMA_FROMDEVICE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
			if (!np->ecdev) dev_kfree_skb(np->rx_skbuff[i]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
			np->rx_skbuff[i] = NULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
static void drain_ring(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
	nv_drain_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
	nv_drain_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
 * nv_start_xmit: dev->hard_start_xmit function
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
 * Called with netif_tx_lock held.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	u32 tx_flags = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
	u32 tx_flags_extra = (np->desc_ver == DESC_VER_1 ? NV_TX_LASTPACKET : NV_TX2_LASTPACKET);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
	unsigned int fragments = skb_shinfo(skb)->nr_frags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
	unsigned int nr = (np->next_tx - 1) % np->tx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	unsigned int start_nr = np->next_tx % np->tx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
	unsigned int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
	u32 offset = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
	u32 bcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
	u32 size = skb->len-skb->data_len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
	u32 entries = (size >> NV_TX2_TSO_MAX_SHIFT) + ((size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
	u32 tx_flags_vlan = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
	/* add fragments to entries count */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
	for (i = 0; i < fragments; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
		entries += (skb_shinfo(skb)->frags[i].size >> NV_TX2_TSO_MAX_SHIFT) +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
			   ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
	if (!np->ecdev) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
        if ((np->next_tx - np->nic_tx + entries - 1) > np->tx_limit_stop) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
            spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
            netif_stop_queue(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
            return NETDEV_TX_BUSY;
586
99df3f4d8d76 Made forcedeth driver compile with 2.6.19.
Florian Pose <fp@igh-essen.com>
parents: 583
diff changeset
  1486
        }
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
	/* setup the header buffer */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
	do {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
		bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
		nr = (nr + 1) % np->tx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
		np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data + offset, bcnt,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
						PCI_DMA_TODEVICE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
		np->tx_dma_len[nr] = bcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
			np->tx_ring.orig[nr].buf = cpu_to_le32(np->tx_dma[nr]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
			np->tx_ring.orig[nr].flaglen = cpu_to_le32((bcnt-1) | tx_flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
			np->tx_ring.ex[nr].bufhigh = cpu_to_le64(np->tx_dma[nr]) >> 32;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
			np->tx_ring.ex[nr].buflow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
			np->tx_ring.ex[nr].flaglen = cpu_to_le32((bcnt-1) | tx_flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
		tx_flags = np->tx_flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
		offset += bcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
		size -= bcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	} while (size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	/* setup the fragments */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
	for (i = 0; i < fragments; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
		u32 size = frag->size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
		offset = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
		do {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
			bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
			nr = (nr + 1) % np->tx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
			np->tx_dma[nr] = pci_map_page(np->pci_dev, frag->page, frag->page_offset+offset, bcnt,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
						      PCI_DMA_TODEVICE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
			np->tx_dma_len[nr] = bcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
			if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
				np->tx_ring.orig[nr].buf = cpu_to_le32(np->tx_dma[nr]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
				np->tx_ring.orig[nr].flaglen = cpu_to_le32((bcnt-1) | tx_flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
			} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
				np->tx_ring.ex[nr].bufhigh = cpu_to_le64(np->tx_dma[nr]) >> 32;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
				np->tx_ring.ex[nr].buflow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
				np->tx_ring.ex[nr].flaglen = cpu_to_le32((bcnt-1) | tx_flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
			offset += bcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
			size -= bcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
		} while (size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
	/* set last fragment flag  */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
		np->tx_ring.orig[nr].flaglen |= cpu_to_le32(tx_flags_extra);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
		np->tx_ring.ex[nr].flaglen |= cpu_to_le32(tx_flags_extra);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
	np->tx_skbuff[nr] = skb;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
#ifdef NETIF_F_TSO
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
	if (skb_is_gso(skb))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
		tx_flags_extra = NV_TX2_TSO | (skb_shinfo(skb)->gso_size << NV_TX2_TSO_SHIFT);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
	tx_flags_extra = skb->ip_summed == CHECKSUM_PARTIAL ?
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
			 NV_TX2_CHECKSUM_L3 | NV_TX2_CHECKSUM_L4 : 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
	/* vlan tag */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
	if (np->vlangrp && vlan_tx_tag_present(skb)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
		tx_flags_vlan = NV_TX3_VLAN_TAG_PRESENT | vlan_tx_tag_get(skb);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
	/* set tx flags */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
		np->tx_ring.orig[start_nr].flaglen |= cpu_to_le32(tx_flags | tx_flags_extra);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
		np->tx_ring.ex[start_nr].txvlan = cpu_to_le32(tx_flags_vlan);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
		np->tx_ring.ex[start_nr].flaglen |= cpu_to_le32(tx_flags | tx_flags_extra);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
	dprintk(KERN_DEBUG "%s: nv_start_xmit: packet %d (entries %d) queued for transmission. tx_flags_extra: %x\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
		dev->name, np->next_tx, entries, tx_flags_extra);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
	{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
		int j;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
		for (j=0; j<64; j++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
			if ((j%16) == 0)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
				dprintk("\n%03x:", j);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
			dprintk(" %02x", ((unsigned char*)skb->data)[j]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
		dprintk("\n");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
	np->next_tx += entries;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
	dev->trans_start = jiffies;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
	if (!np->ecdev) spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	pci_push(get_hwbase(dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
	return NETDEV_TX_OK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
 * nv_tx_done: check for completed packets, release the skbs.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
 * Caller must own np->lock.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
static void nv_tx_done(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
	u32 flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
	unsigned int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
	struct sk_buff *skb;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
	while (np->nic_tx != np->next_tx) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
		i = np->nic_tx % np->tx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
			flags = le32_to_cpu(np->tx_ring.orig[i].flaglen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
			flags = le32_to_cpu(np->tx_ring.ex[i].flaglen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
		dprintk(KERN_DEBUG "%s: nv_tx_done: looking at packet %d, flags 0x%x.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
					dev->name, np->nic_tx, flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
		if (flags & NV_TX_VALID)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
		if (np->desc_ver == DESC_VER_1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
			if (flags & NV_TX_LASTPACKET) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
				skb = np->tx_skbuff[i];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
				if (flags & (NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION|
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
					     NV_TX_UNDERFLOW|NV_TX_ERROR)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
					if (flags & NV_TX_UNDERFLOW)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
						np->stats.tx_fifo_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
					if (flags & NV_TX_CARRIERLOST)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
						np->stats.tx_carrier_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
					np->stats.tx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
				} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
					np->stats.tx_packets++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
					np->stats.tx_bytes += skb->len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
			if (flags & NV_TX2_LASTPACKET) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
				skb = np->tx_skbuff[i];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
				if (flags & (NV_TX2_RETRYERROR|NV_TX2_CARRIERLOST|NV_TX2_LATECOLLISION|
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
					     NV_TX2_UNDERFLOW|NV_TX2_ERROR)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
					if (flags & NV_TX2_UNDERFLOW)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
						np->stats.tx_fifo_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
					if (flags & NV_TX2_CARRIERLOST)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
						np->stats.tx_carrier_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
					np->stats.tx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
				} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
					np->stats.tx_packets++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
					np->stats.tx_bytes += skb->len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
		nv_release_txskb(dev, i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
		np->nic_tx++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
	if (!np->ecdev && np->next_tx - np->nic_tx < np->tx_limit_start)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
		netif_wake_queue(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
 * nv_tx_timeout: dev->tx_timeout function
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
 * Called with netif_tx_lock held.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
static void nv_tx_timeout(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	u32 status;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
	if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
		status = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQSTAT_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
		status = readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
	printk(KERN_INFO "%s: Got tx_timeout. irq: %08x\n", dev->name, status);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
	{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
		int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
		printk(KERN_INFO "%s: Ring at %lx: next %d nic %d\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
				dev->name, (unsigned long)np->ring_addr,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
				np->next_tx, np->nic_tx);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
		printk(KERN_INFO "%s: Dumping tx registers\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
		for (i=0;i<=np->register_size;i+= 32) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
			printk(KERN_INFO "%3x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
					i,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
					readl(base + i + 0), readl(base + i + 4),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
					readl(base + i + 8), readl(base + i + 12),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
					readl(base + i + 16), readl(base + i + 20),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
					readl(base + i + 24), readl(base + i + 28));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		printk(KERN_INFO "%s: Dumping tx ring\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		for (i=0;i<np->tx_ring_size;i+= 4) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
			if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
				printk(KERN_INFO "%03x: %08x %08x // %08x %08x // %08x %08x // %08x %08x\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
				       i,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
				       le32_to_cpu(np->tx_ring.orig[i].buf),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
				       le32_to_cpu(np->tx_ring.orig[i].flaglen),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
				       le32_to_cpu(np->tx_ring.orig[i+1].buf),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
				       le32_to_cpu(np->tx_ring.orig[i+1].flaglen),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
				       le32_to_cpu(np->tx_ring.orig[i+2].buf),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
				       le32_to_cpu(np->tx_ring.orig[i+2].flaglen),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
				       le32_to_cpu(np->tx_ring.orig[i+3].buf),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
				       le32_to_cpu(np->tx_ring.orig[i+3].flaglen));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
			} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
				printk(KERN_INFO "%03x: %08x %08x %08x // %08x %08x %08x // %08x %08x %08x // %08x %08x %08x\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
				       i,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
				       le32_to_cpu(np->tx_ring.ex[i].bufhigh),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
				       le32_to_cpu(np->tx_ring.ex[i].buflow),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
				       le32_to_cpu(np->tx_ring.ex[i].flaglen),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
				       le32_to_cpu(np->tx_ring.ex[i+1].bufhigh),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
				       le32_to_cpu(np->tx_ring.ex[i+1].buflow),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
				       le32_to_cpu(np->tx_ring.ex[i+1].flaglen),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
				       le32_to_cpu(np->tx_ring.ex[i+2].bufhigh),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
				       le32_to_cpu(np->tx_ring.ex[i+2].buflow),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
				       le32_to_cpu(np->tx_ring.ex[i+2].flaglen),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
				       le32_to_cpu(np->tx_ring.ex[i+3].bufhigh),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
				       le32_to_cpu(np->tx_ring.ex[i+3].buflow),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
				       le32_to_cpu(np->tx_ring.ex[i+3].flaglen));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
	if (!np->ecdev) spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
	/* 1) stop tx engine */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
	nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
	/* 2) check that the packets were not sent already: */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
	nv_tx_done(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
	/* 3) if there are dead entries: clear everything */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
	if (np->next_tx != np->nic_tx) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
		printk(KERN_DEBUG "%s: tx_timeout: dead entries!\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
		nv_drain_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
		np->next_tx = np->nic_tx = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
		setup_hw_rings(dev, NV_SETUP_TX_RING);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
		if (!np->ecdev) netif_wake_queue(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
	/* 4) restart tx engine */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
	nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
	if (!np->ecdev) spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
 * Called when the nic notices a mismatch between the actual data len on the
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
 * wire and the len indicated in the 802 header
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
static int nv_getlen(struct net_device *dev, void *packet, int datalen)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
	int hdrlen;	/* length of the 802 header */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
	int protolen;	/* length as stored in the proto field */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
	/* 1) calculate len according to header */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
	if ( ((struct vlan_ethhdr *)packet)->h_vlan_proto == htons(ETH_P_8021Q)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
		protolen = ntohs( ((struct vlan_ethhdr *)packet)->h_vlan_encapsulated_proto );
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
		hdrlen = VLAN_HLEN;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
		protolen = ntohs( ((struct ethhdr *)packet)->h_proto);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
		hdrlen = ETH_HLEN;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
	dprintk(KERN_DEBUG "%s: nv_getlen: datalen %d, protolen %d, hdrlen %d\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
				dev->name, datalen, protolen, hdrlen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
	if (protolen > ETH_DATA_LEN)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		return datalen; /* Value in proto field not a len, no checks possible */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
	protolen += hdrlen;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
	/* consistency checks: */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
	if (datalen > ETH_ZLEN) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
		if (datalen >= protolen) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
			/* more data on wire than in 802 header, trim of
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
			 * additional data.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
			 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
			dprintk(KERN_DEBUG "%s: nv_getlen: accepting %d bytes.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
					dev->name, protolen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
			return protolen;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
			/* less data on wire than mentioned in header.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
			 * Discard the packet.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
			 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
			dprintk(KERN_DEBUG "%s: nv_getlen: discarding long packet.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
					dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
			return -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
		/* short packet. Accept only if 802 values are also short */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
		if (protolen > ETH_ZLEN) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
			dprintk(KERN_DEBUG "%s: nv_getlen: discarding short packet.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
					dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
			return -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
		dprintk(KERN_DEBUG "%s: nv_getlen: accepting %d bytes.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
				dev->name, datalen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
		return datalen;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
static int nv_rx_process(struct net_device *dev, int limit)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
	u32 flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	u32 vlanflags = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	int count;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
 	for (count = 0; count < limit; ++count) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
		struct sk_buff *skb;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
		int len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
		int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
		if (np->cur_rx - np->refill_rx >= np->rx_ring_size)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
			break;	/* we scanned the whole ring - do not continue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
		i = np->cur_rx % np->rx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
			flags = le32_to_cpu(np->rx_ring.orig[i].flaglen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
			len = nv_descr_getlength(&np->rx_ring.orig[i], np->desc_ver);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
			flags = le32_to_cpu(np->rx_ring.ex[i].flaglen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
			len = nv_descr_getlength_ex(&np->rx_ring.ex[i], np->desc_ver);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
			vlanflags = le32_to_cpu(np->rx_ring.ex[i].buflow);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
		dprintk(KERN_DEBUG "%s: nv_rx_process: looking at packet %d, flags 0x%x.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
					dev->name, np->cur_rx, flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
		if (flags & NV_RX_AVAIL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
			break;	/* still owned by hardware, */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
		/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
		 * the packet is for us - immediately tear down the pci mapping.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
		 * TODO: check if a prefetch of the first cacheline improves
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
		 * the performance.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
		 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
		pci_unmap_single(np->pci_dev, np->rx_dma[i],
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
				np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
				PCI_DMA_FROMDEVICE);
586
99df3f4d8d76 Made forcedeth driver compile with 2.6.19.
Florian Pose <fp@igh-essen.com>
parents: 583
diff changeset
  1828
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
		{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
			int j;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
			dprintk(KERN_DEBUG "Dumping packet (flags 0x%x).",flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
			for (j=0; j<64; j++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
				if ((j%16) == 0)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
					dprintk("\n%03x:", j);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
				dprintk(" %02x", ((unsigned char*)np->rx_skbuff[i]->data)[j]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
			dprintk("\n");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
		/* look at what we actually got: */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
		if (np->desc_ver == DESC_VER_1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
			if (!(flags & NV_RX_DESCRIPTORVALID))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
				goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
			if (flags & NV_RX_ERROR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
				if (flags & NV_RX_MISSEDFRAME) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
					np->stats.rx_missed_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
					np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
					goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
				if (flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
					np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
					goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
				if (flags & NV_RX_CRCERR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
					np->stats.rx_crc_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
					np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
					goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
				if (flags & NV_RX_OVERFLOW) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
					np->stats.rx_over_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
					np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
					goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
				if (flags & NV_RX_ERROR4) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
					len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
					if (len < 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
						np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
						goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
					}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
				/* framing errors are soft errors. */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
				if (flags & NV_RX_FRAMINGERR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
					if (flags & NV_RX_SUBSTRACT1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
						len--;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
					}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
			if (!(flags & NV_RX2_DESCRIPTORVALID))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
				goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
			if (flags & NV_RX2_ERROR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
				if (flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
					np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
					goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
				if (flags & NV_RX2_CRCERR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
					np->stats.rx_crc_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
					np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
					goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
				if (flags & NV_RX2_OVERFLOW) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
					np->stats.rx_over_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
					np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
					goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
				if (flags & NV_RX2_ERROR4) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
					len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
					if (len < 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
						np->stats.rx_errors++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
						goto next_pkt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
					}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
				/* framing errors are soft errors */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
				if (flags & NV_RX2_FRAMINGERR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
					if (flags & NV_RX2_SUBSTRACT1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
						len--;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
					}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
			if (np->rx_csum) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
				flags &= NV_RX2_CHECKSUMMASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
				if (flags == NV_RX2_CHECKSUMOK1 ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
				    flags == NV_RX2_CHECKSUMOK2 ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
				    flags == NV_RX2_CHECKSUMOK3) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
					dprintk(KERN_DEBUG "%s: hw checksum hit!.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
					np->rx_skbuff[i]->ip_summed = CHECKSUM_UNNECESSARY;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
				} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
					dprintk(KERN_DEBUG "%s: hwchecksum miss!.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		if (np->ecdev) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
			ecdev_receive(np->ecdev, np->rx_skbuff[i]->data, len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
		else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
			/* got a valid packet - forward it to the network core */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
			skb = np->rx_skbuff[i];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
			np->rx_skbuff[i] = NULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
			skb_put(skb, len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
			skb->protocol = eth_type_trans(skb, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
			dprintk(KERN_DEBUG "%s: nv_rx_process: packet %d with %d bytes, proto %d accepted.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
					dev->name, np->cur_rx, len, skb->protocol);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
#ifdef CONFIG_FORCEDETH_NAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
			if (np->vlangrp && (vlanflags & NV_RX3_VLAN_TAG_PRESENT))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
				vlan_hwaccel_receive_skb(skb, np->vlangrp,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
						vlanflags & NV_RX3_VLAN_TAG_MASK);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
			else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
				netif_receive_skb(skb);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
#else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
			if (np->vlangrp && (vlanflags & NV_RX3_VLAN_TAG_PRESENT))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
				vlan_hwaccel_rx(skb, np->vlangrp,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
						vlanflags & NV_RX3_VLAN_TAG_MASK);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
			else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
				netif_rx(skb);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
		dev->last_rx = jiffies;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
		np->stats.rx_packets++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
		np->stats.rx_bytes += len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
next_pkt:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
		np->cur_rx++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
	return count;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
static void set_bufsize(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
	if (dev->mtu <= ETH_DATA_LEN)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
		np->rx_buf_sz = ETH_DATA_LEN + NV_RX_HEADERS;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
		np->rx_buf_sz = dev->mtu + NV_RX_HEADERS;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
 * nv_change_mtu: dev->change_mtu function
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
 * Called with dev_base_lock held for read.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
static int nv_change_mtu(struct net_device *dev, int new_mtu)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
	int old_mtu;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
	if (new_mtu < 64 || new_mtu > np->pkt_limit)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
	old_mtu = dev->mtu;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
	dev->mtu = new_mtu;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	/* return early if the buffer sizes will not change */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
	if (old_mtu <= ETH_DATA_LEN && new_mtu <= ETH_DATA_LEN)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
	if (old_mtu == new_mtu)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
	/* synchronized against open : rtnl_lock() held by caller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
		u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
		/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
		 * It seems that the nic preloads valid ring entries into an
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
		 * internal buffer. The procedure for flushing everything is
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
		 * guessed, there is probably a simpler approach.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
		 * Changing the MTU is a rare event, it shouldn't matter.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
		 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
		nv_disable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
		netif_tx_lock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
		spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
		/* stop engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
		nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
		nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
		nv_txrx_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
		/* drain rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
		nv_drain_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
		nv_drain_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
		/* reinit driver view of the rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
		set_bufsize(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
		if (nv_init_ring(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
			if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
				mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
		/* reinit nic view of the rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
		writel(np->rx_buf_sz, base + NvRegOffloadConfig);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
		setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
		writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
			base + NvRegRingSizes);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
		writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
		/* restart rx engine */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
		nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
		nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
		spin_unlock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
		netif_tx_unlock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
		nv_enable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
static void nv_copy_mac_to_hw(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
	u32 mac[2];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
	mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
			(dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
	mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
	writel(mac[0], base + NvRegMacAddrA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
	writel(mac[1], base + NvRegMacAddrB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
 * nv_set_mac_address: dev->set_mac_address function
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
 * Called with rtnl_lock() held.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
static int nv_set_mac_address(struct net_device *dev, void *addr)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
	struct sockaddr *macaddr = (struct sockaddr*)addr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
	if (!is_valid_ether_addr(macaddr->sa_data))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
		return -EADDRNOTAVAIL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
	/* synchronized against open : rtnl_lock() held by caller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
	memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
		netif_tx_lock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
		/* stop rx engine */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
		nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
		/* set mac address */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
		nv_copy_mac_to_hw(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
		/* restart rx engine */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
		nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
		netif_tx_unlock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
		nv_copy_mac_to_hw(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
 * nv_set_multicast: dev->set_multicast function
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
 * Called with netif_tx_lock held.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
static void nv_set_multicast(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
	u32 addr[2];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
	u32 mask[2];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
	u32 pff = readl(base + NvRegPacketFilterFlags) & NVREG_PFF_PAUSE_RX;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
	memset(addr, 0, sizeof(addr));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
	memset(mask, 0, sizeof(mask));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
	if (dev->flags & IFF_PROMISC) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
		pff |= NVREG_PFF_PROMISC;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
		pff |= NVREG_PFF_MYADDR;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
		if (dev->flags & IFF_ALLMULTI || dev->mc_list) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
			u32 alwaysOff[2];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
			u32 alwaysOn[2];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
			alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0xffffffff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
			if (dev->flags & IFF_ALLMULTI) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
				alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
			} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
				struct dev_mc_list *walk;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
				walk = dev->mc_list;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
				while (walk != NULL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
					u32 a, b;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
					a = le32_to_cpu(*(u32 *) walk->dmi_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
					b = le16_to_cpu(*(u16 *) (&walk->dmi_addr[4]));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
					alwaysOn[0] &= a;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
					alwaysOff[0] &= ~a;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
					alwaysOn[1] &= b;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
					alwaysOff[1] &= ~b;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
					walk = walk->next;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
			addr[0] = alwaysOn[0];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
			addr[1] = alwaysOn[1];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
			mask[0] = alwaysOn[0] | alwaysOff[0];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
			mask[1] = alwaysOn[1] | alwaysOff[1];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
	addr[0] |= NVREG_MCASTADDRA_FORCE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
	pff |= NVREG_PFF_ALWAYS;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
	spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
	nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
	writel(addr[0], base + NvRegMulticastAddrA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
	writel(addr[1], base + NvRegMulticastAddrB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	writel(mask[0], base + NvRegMulticastMaskA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
	writel(mask[1], base + NvRegMulticastMaskB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
	writel(pff, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	dprintk(KERN_INFO "%s: reconfiguration for multicast lists.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
		dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
	nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
	spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
static void nv_update_pause(struct net_device *dev, u32 pause_flags)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
	np->pause_flags &= ~(NV_PAUSEFRAME_TX_ENABLE | NV_PAUSEFRAME_RX_ENABLE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
	if (np->pause_flags & NV_PAUSEFRAME_RX_CAPABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
		u32 pff = readl(base + NvRegPacketFilterFlags) & ~NVREG_PFF_PAUSE_RX;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
		if (pause_flags & NV_PAUSEFRAME_RX_ENABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
			writel(pff|NVREG_PFF_PAUSE_RX, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
			np->pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
			writel(pff, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
	if (np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
		u32 regmisc = readl(base + NvRegMisc1) & ~NVREG_MISC1_PAUSE_TX;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
		if (pause_flags & NV_PAUSEFRAME_TX_ENABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
			writel(NVREG_TX_PAUSEFRAME_ENABLE,  base + NvRegTxPauseFrame);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
			writel(regmisc|NVREG_MISC1_PAUSE_TX, base + NvRegMisc1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
			np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
			writel(NVREG_TX_PAUSEFRAME_DISABLE,  base + NvRegTxPauseFrame);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
			writel(regmisc, base + NvRegMisc1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
/**
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
 * nv_update_linkspeed: Setup the MAC according to the link partner
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
 * @dev: Network device to be configured
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
 * The function queries the PHY and checks if there is a link partner.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
 * If yes, then it sets up the MAC accordingly. Otherwise, the MAC is
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
 * set to 10 MBit HD.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
 *
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
 * The function returns 0 if there is no link partner and 1 if there is
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
 * a good link partner.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
static int nv_update_linkspeed(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
	int adv = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
	int lpa = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
	int adv_lpa, adv_pause, lpa_pause;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
	int newls = np->linkspeed;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
	int newdup = np->duplex;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
	int mii_status;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
	int retval = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
	u32 control_1000, status_1000, phyreg, pause_flags, txreg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
	/* BMSR_LSTATUS is latched, read it twice:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
	 * we want the current value.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
	mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
	mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
	if (!(mii_status & BMSR_LSTATUS)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
		dprintk(KERN_DEBUG "%s: no link detected by phy - falling back to 10HD.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
				dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
		newdup = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
		retval = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
		goto set_speed;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
	if (np->autoneg == 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
		dprintk(KERN_DEBUG "%s: nv_update_linkspeed: autoneg off, PHY set to 0x%04x.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
				dev->name, np->fixed_mode);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
		if (np->fixed_mode & LPA_100FULL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
			newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
			newdup = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
		} else if (np->fixed_mode & LPA_100HALF) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
			newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
			newdup = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
		} else if (np->fixed_mode & LPA_10FULL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
			newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
			newdup = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
			newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
			newdup = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
		retval = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
		goto set_speed;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
	/* check auto negotiation is complete */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
	if (!(mii_status & BMSR_ANEGCOMPLETE)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
		/* still in autonegotiation - configure nic for 10 MBit HD and wait. */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
		newdup = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
		retval = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
		dprintk(KERN_DEBUG "%s: autoneg not completed - falling back to 10HD.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
		goto set_speed;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
	adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
	lpa = mii_rw(dev, np->phyaddr, MII_LPA, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
	dprintk(KERN_DEBUG "%s: nv_update_linkspeed: PHY advertises 0x%04x, lpa 0x%04x.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
				dev->name, adv, lpa);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
	retval = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
	if (np->gigabit == PHY_GIGABIT) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
		control_1000 = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
		status_1000 = mii_rw(dev, np->phyaddr, MII_STAT1000, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
		if ((control_1000 & ADVERTISE_1000FULL) &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
			(status_1000 & LPA_1000FULL)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
			dprintk(KERN_DEBUG "%s: nv_update_linkspeed: GBit ethernet detected.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
				dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
			newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_1000;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
			newdup = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
			goto set_speed;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	/* FIXME: handle parallel detection properly */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
	adv_lpa = lpa & adv;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	if (adv_lpa & LPA_100FULL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
		newdup = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
	} else if (adv_lpa & LPA_100HALF) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
		newdup = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
	} else if (adv_lpa & LPA_10FULL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
		newdup = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
	} else if (adv_lpa & LPA_10HALF) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
		newdup = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
		dprintk(KERN_DEBUG "%s: bad ability %04x - falling back to 10HD.\n", dev->name, adv_lpa);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
		newdup = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
set_speed:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	if (np->duplex == newdup && np->linkspeed == newls)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
		return retval;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	dprintk(KERN_INFO "%s: changing link setting from %d/%d to %d/%d.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
			dev->name, np->linkspeed, np->duplex, newls, newdup);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
	np->duplex = newdup;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
	np->linkspeed = newls;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
	if (np->gigabit == PHY_GIGABIT) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
		phyreg = readl(base + NvRegRandomSeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
		phyreg &= ~(0x3FF00);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
		if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_10)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
			phyreg |= NVREG_RNDSEED_FORCE3;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
		else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_100)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
			phyreg |= NVREG_RNDSEED_FORCE2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
		else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_1000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
			phyreg |= NVREG_RNDSEED_FORCE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
		writel(phyreg, base + NvRegRandomSeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
	phyreg = readl(base + NvRegPhyInterface);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
	phyreg &= ~(PHY_HALF|PHY_100|PHY_1000);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
	if (np->duplex == 0)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
		phyreg |= PHY_HALF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
	if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_100)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
		phyreg |= PHY_100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	else if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_1000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
		phyreg |= PHY_1000;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
	writel(phyreg, base + NvRegPhyInterface);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
	if (phyreg & PHY_RGMII) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
		if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_1000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
			txreg = NVREG_TX_DEFERRAL_RGMII_1000;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
			txreg = NVREG_TX_DEFERRAL_RGMII_10_100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
		txreg = NVREG_TX_DEFERRAL_DEFAULT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
	writel(txreg, base + NvRegTxDeferral);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
	if (np->desc_ver == DESC_VER_1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
		txreg = NVREG_TX_WM_DESC1_DEFAULT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
		if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_1000)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
			txreg = NVREG_TX_WM_DESC2_3_1000;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
			txreg = NVREG_TX_WM_DESC2_3_DEFAULT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
	writel(txreg, base + NvRegTxWatermark);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
	writel(NVREG_MISC1_FORCE | ( np->duplex ? 0 : NVREG_MISC1_HD),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
		base + NvRegMisc1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
	writel(np->linkspeed, base + NvRegLinkSpeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
	pause_flags = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
	/* setup pause frame */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
	if (np->duplex != 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
		if (np->autoneg && np->pause_flags & NV_PAUSEFRAME_AUTONEG) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
			adv_pause = adv & (ADVERTISE_PAUSE_CAP| ADVERTISE_PAUSE_ASYM);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
			lpa_pause = lpa & (LPA_PAUSE_CAP| LPA_PAUSE_ASYM);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
			switch (adv_pause) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
			case ADVERTISE_PAUSE_CAP:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
				if (lpa_pause & LPA_PAUSE_CAP) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
					pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
					if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
						pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
				break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
			case ADVERTISE_PAUSE_ASYM:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
				if (lpa_pause == (LPA_PAUSE_CAP| LPA_PAUSE_ASYM))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
				{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
					pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
				break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
			case ADVERTISE_PAUSE_CAP| ADVERTISE_PAUSE_ASYM:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
				if (lpa_pause & LPA_PAUSE_CAP)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
				{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
					pause_flags |=  NV_PAUSEFRAME_RX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
					if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
						pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
				if (lpa_pause == LPA_PAUSE_ASYM)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
				{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
					pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
				break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
			pause_flags = np->pause_flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
	nv_update_pause(dev, pause_flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
	return retval;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
static void nv_linkchange(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
    if (np->ecdev) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2388
        int link = nv_update_linkspeed(dev);
670
f57de4585a5f Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
  2389
        ecdev_set_link(np->ecdev, link);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
        return;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
    }
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
	if (nv_update_linkspeed(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
		if (!netif_carrier_ok(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
			netif_carrier_on(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
			printk(KERN_INFO "%s: link up.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
			nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
		if (netif_carrier_ok(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
			netif_carrier_off(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
			printk(KERN_INFO "%s: link down.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
			nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
static void nv_link_irq(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
	u32 miistat;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
	miistat = readl(base + NvRegMIIStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
	writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
	dprintk(KERN_INFO "%s: link change irq, status 0x%x.\n", dev->name, miistat);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
	if (miistat & (NVREG_MIISTAT_LINKCHANGE))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
		nv_linkchange(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
	dprintk(KERN_DEBUG "%s: link change notification done.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
static irqreturn_t nv_nic_irq(int foo, void *data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
	u32 events;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
	dprintk(KERN_DEBUG "%s: nv_nic_irq\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
	for (i=0; ; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
		if (!(np->msi_flags & NV_MSI_X_ENABLED)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
			events = readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
			writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
			events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQSTAT_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
			writel(NVREG_IRQSTAT_MASK, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
		dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
		if (!(events & np->irqmask))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2445
		if (!np->ecdev) spin_lock(&np->lock);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
		nv_tx_done(dev);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2447
		if (!np->ecdev) spin_unlock(&np->lock);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
		if (events & NVREG_IRQ_LINK) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2450
			if (!np->ecdev) spin_lock(&np->lock);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
			nv_link_irq(dev);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2452
			if (!np->ecdev) spin_unlock(&np->lock);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
		if (np->need_linktimer && time_after(jiffies, np->link_timeout)) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2455
			if (!np->ecdev) spin_lock(&np->lock);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
			nv_linkchange(dev);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2457
			if (!np->ecdev) spin_unlock(&np->lock);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
			np->link_timeout = jiffies + LINK_TIMEOUT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
		if (events & (NVREG_IRQ_TX_ERR)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
			dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
						dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
		if (events & (NVREG_IRQ_UNKNOWN)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
			printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
						dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
#ifdef CONFIG_FORCEDETH_NAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
		if (events & NVREG_IRQ_RX_ALL) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2470
			if (np->ecdev) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2471
				nv_rx_process(dev, dev->weight);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2472
			}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2473
			else {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2474
				netif_rx_schedule(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2475
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2476
				/* Disable furthur receive irq's */
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2477
				spin_lock(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2478
				np->irqmask &= ~NVREG_IRQ_RX_ALL;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2479
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2480
				if (np->msi_flags & NV_MSI_X_ENABLED)
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2481
					writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2482
				else
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2483
					writel(np->irqmask, base + NvRegIrqMask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2484
				spin_unlock(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2485
			}
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
#else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
		nv_rx_process(dev, dev->weight);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2489
		if (nv_alloc_rx(dev) && !np->ecdev) {
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
			spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
			if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
				mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
			spin_unlock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
		if (i > max_interrupt_work) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2497
			if (!np->ecdev) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2498
				spin_lock(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2499
				/* disable interrupts on the nic */
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2500
				if (!(np->msi_flags & NV_MSI_X_ENABLED))
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2501
					writel(0, base + NvRegIrqMask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2502
				else
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2503
					writel(np->irqmask, base + NvRegIrqMask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2504
				pci_push(base);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2505
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2506
				if (!np->in_shutdown) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2507
					np->nic_poll_irq = np->irqmask;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2508
					mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2509
				}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2510
				spin_unlock(&np->lock);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
			printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq.\n", dev->name, i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
	dprintk(KERN_DEBUG "%s: nv_nic_irq completed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	return IRQ_RETVAL(i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
static irqreturn_t nv_nic_irq_tx(int foo, void *data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	u32 events;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
	int i;
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2529
	unsigned long flags = 0;
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
	dprintk(KERN_DEBUG "%s: nv_nic_irq_tx\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
	for (i=0; ; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
		events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQ_TX_ALL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
		writel(NVREG_IRQ_TX_ALL, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
		dprintk(KERN_DEBUG "%s: tx irq: %08x\n", dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
		if (!(events & np->irqmask))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2541
		if (!np->ecdev) spin_lock_irqsave(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
		nv_tx_done(dev);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2543
		if (!np->ecdev) spin_unlock_irqrestore(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
		if (events & (NVREG_IRQ_TX_ERR)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
			dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
						dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
		if (i > max_interrupt_work) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2550
			if (!np->ecdev) { 
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2551
				spin_lock_irqsave(&np->lock, flags);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2552
				/* disable interrupts on the nic */
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2553
				writel(NVREG_IRQ_TX_ALL, base + NvRegIrqMask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2554
				pci_push(base);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2555
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2556
				if (!np->in_shutdown) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2557
					np->nic_poll_irq |= NVREG_IRQ_TX_ALL;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2558
					mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2559
				}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2560
				spin_unlock_irqrestore(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
			printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
	dprintk(KERN_DEBUG "%s: nv_nic_irq_tx completed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	return IRQ_RETVAL(i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
#ifdef CONFIG_FORCEDETH_NAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
static int nv_napi_poll(struct net_device *dev, int *budget)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
	int pkts, limit = min(*budget, dev->quota);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
	pkts = nv_rx_process(dev, limit);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
	if (nv_alloc_rx(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
		if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
			mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
		spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
	if (pkts < limit) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
		/* all done, no more packets present */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
		netif_rx_complete(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
		/* re-enable receive interrupts */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
		np->irqmask |= NVREG_IRQ_RX_ALL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
		if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
			writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
			writel(np->irqmask, base + NvRegIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
		spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
		/* used up our quantum, so reschedule */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
		dev->quota -= pkts;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
		*budget -= pkts;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
		return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
#ifdef CONFIG_FORCEDETH_NAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
static irqreturn_t nv_nic_irq_rx(int foo, void *data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
	struct net_device *dev = (struct net_device *) data;
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2614
	struct fe_priv *np = netdev_priv(dev);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
	u32 events;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
	events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQ_RX_ALL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
	writel(NVREG_IRQ_RX_ALL, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2621
	if (events && !np->ecdev) {
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
		netif_rx_schedule(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
		/* disable receive interrupts on the nic */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
		writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
	return IRQ_HANDLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
#else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
static irqreturn_t nv_nic_irq_rx(int foo, void *data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
	u32 events;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
	unsigned long flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
	dprintk(KERN_DEBUG "%s: nv_nic_irq_rx\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
	for (i=0; ; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
		events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQ_RX_ALL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
		writel(NVREG_IRQ_RX_ALL, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
		dprintk(KERN_DEBUG "%s: rx irq: %08x\n", dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
		if (!(events & np->irqmask))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
		nv_rx_process(dev, dev->weight);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2650
		if (nv_alloc_rx(dev) && !np->ecdev) {
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
			spin_lock_irqsave(&np->lock, flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
			if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
				mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
			spin_unlock_irqrestore(&np->lock, flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
		if (i > max_interrupt_work) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2658
			if (!np->ecdev) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2659
				spin_lock_irqsave(&np->lock, flags);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2660
				/* disable interrupts on the nic */
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2661
				writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2662
				pci_push(base);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2663
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2664
				if (!np->in_shutdown) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2665
					np->nic_poll_irq |= NVREG_IRQ_RX_ALL;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2666
					mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2667
				}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2668
				spin_unlock_irqrestore(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
			printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
	dprintk(KERN_DEBUG "%s: nv_nic_irq_rx completed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
	return IRQ_RETVAL(i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
static irqreturn_t nv_nic_irq_other(int foo, void *data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
	u32 events;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
	int i;
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2687
	unsigned long flags = 0;
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
	dprintk(KERN_DEBUG "%s: nv_nic_irq_other\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
	for (i=0; ; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
		events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQ_OTHER;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
		writel(NVREG_IRQ_OTHER, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
		dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
		if (!(events & np->irqmask))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
		if (events & NVREG_IRQ_LINK) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2700
			if (!np->ecdev) spin_lock_irqsave(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
			nv_link_irq(dev);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2702
			if (!np->ecdev) spin_unlock_irqrestore(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
		if (np->need_linktimer && time_after(jiffies, np->link_timeout)) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2705
			if (!np->ecdev) spin_lock_irqsave(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
			nv_linkchange(dev);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2707
			if (!np->ecdev) spin_unlock_irqrestore(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
			np->link_timeout = jiffies + LINK_TIMEOUT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
		if (events & (NVREG_IRQ_UNKNOWN)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
			printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
						dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
		if (i > max_interrupt_work) {
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2715
			if (!np->ecdev) { 
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2716
				spin_lock_irqsave(&np->lock, flags);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2717
				/* disable interrupts on the nic */
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2718
				writel(NVREG_IRQ_OTHER, base + NvRegIrqMask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2719
				pci_push(base);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2720
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2721
				if (!np->in_shutdown) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2722
					np->nic_poll_irq |= NVREG_IRQ_OTHER;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2723
					mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2724
				}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2725
				spin_unlock_irqrestore(&np->lock, flags);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
			printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
	dprintk(KERN_DEBUG "%s: nv_nic_irq_other completed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
	return IRQ_RETVAL(i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
static irqreturn_t nv_nic_irq_test(int foo, void *data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
	u32 events;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
	dprintk(KERN_DEBUG "%s: nv_nic_irq_test\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
	if (!(np->msi_flags & NV_MSI_X_ENABLED)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
		events = readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
		writel(NVREG_IRQ_TIMER, base + NvRegIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
		events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQSTAT_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
		writel(NVREG_IRQ_TIMER, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
	dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
	if (!(events & NVREG_IRQ_TIMER))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
		return IRQ_RETVAL(0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
	spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
	np->intr_test = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
	spin_unlock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
	dprintk(KERN_DEBUG "%s: nv_nic_irq_test completed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
	return IRQ_RETVAL(1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
static void set_msix_vector_map(struct net_device *dev, u32 vector, u32 irqmask)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
	u32 msixmap = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
	/* Each interrupt bit can be mapped to a MSIX vector (4 bits).
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
	 * MSIXMap0 represents the first 8 interrupts and MSIXMap1 represents
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
	 * the remaining 8 interrupts.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
	for (i = 0; i < 8; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
		if ((irqmask >> i) & 0x1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
			msixmap |= vector << (i << 2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
	writel(readl(base + NvRegMSIXMap0) | msixmap, base + NvRegMSIXMap0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
	msixmap = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
	for (i = 0; i < 8; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
		if ((irqmask >> (i + 8)) & 0x1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
			msixmap |= vector << (i << 2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
	writel(readl(base + NvRegMSIXMap1) | msixmap, base + NvRegMSIXMap1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
static int nv_request_irq(struct net_device *dev, int intr_test)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
	int ret = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
	if (np->msi_flags & NV_MSI_X_CAPABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
		for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
			np->msi_x_entry[i].entry = i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
		if ((ret = pci_enable_msix(np->pci_dev, np->msi_x_entry, (np->msi_flags & NV_MSI_X_VECTORS_MASK))) == 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
			np->msi_flags |= NV_MSI_X_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
			if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT && !intr_test) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
				/* Request irq for rx handling */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
				if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, &nv_nic_irq_rx, IRQF_SHARED, dev->name, dev) != 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
					printk(KERN_INFO "forcedeth: request_irq failed for rx %d\n", ret);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
					pci_disable_msix(np->pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
					np->msi_flags &= ~NV_MSI_X_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
					goto out_err;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
				/* Request irq for tx handling */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
				if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, &nv_nic_irq_tx, IRQF_SHARED, dev->name, dev) != 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
					printk(KERN_INFO "forcedeth: request_irq failed for tx %d\n", ret);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
					pci_disable_msix(np->pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
					np->msi_flags &= ~NV_MSI_X_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
					goto out_free_rx;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
				/* Request irq for link and timer handling */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
				if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector, &nv_nic_irq_other, IRQF_SHARED, dev->name, dev) != 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
					printk(KERN_INFO "forcedeth: request_irq failed for link %d\n", ret);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
					pci_disable_msix(np->pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
					np->msi_flags &= ~NV_MSI_X_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
					goto out_free_tx;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
				/* map interrupts to their respective vector */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
				writel(0, base + NvRegMSIXMap0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
				writel(0, base + NvRegMSIXMap1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
				set_msix_vector_map(dev, NV_MSI_X_VECTOR_RX, NVREG_IRQ_RX_ALL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
				set_msix_vector_map(dev, NV_MSI_X_VECTOR_TX, NVREG_IRQ_TX_ALL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
				set_msix_vector_map(dev, NV_MSI_X_VECTOR_OTHER, NVREG_IRQ_OTHER);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
			} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
				/* Request irq for all interrupts */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
				if ((!intr_test &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
				     request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq, IRQF_SHARED, dev->name, dev) != 0) ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
				    (intr_test &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
				     request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq_test, IRQF_SHARED, dev->name, dev) != 0)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
					printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
					pci_disable_msix(np->pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
					np->msi_flags &= ~NV_MSI_X_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
					goto out_err;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
				/* map interrupts to vector 0 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
				writel(0, base + NvRegMSIXMap0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
				writel(0, base + NvRegMSIXMap1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
	if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
		if ((ret = pci_enable_msi(np->pci_dev)) == 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
			pci_intx(np->pci_dev, 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
			np->msi_flags |= NV_MSI_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
			if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, IRQF_SHARED, dev->name, dev) != 0) ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
			    (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, IRQF_SHARED, dev->name, dev) != 0)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
				printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
				pci_disable_msi(np->pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
				pci_intx(np->pci_dev, 1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
				np->msi_flags &= ~NV_MSI_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
				goto out_err;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
			/* map interrupts to vector 0 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
			writel(0, base + NvRegMSIMap0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
			writel(0, base + NvRegMSIMap1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
			/* enable msi vector 0 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
			writel(NVREG_MSI_VECTOR_0_ENABLED, base + NvRegMSIIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
	if (ret != 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
		if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, IRQF_SHARED, dev->name, dev) != 0) ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
		    (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, IRQF_SHARED, dev->name, dev) != 0))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
			goto out_err;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
out_free_tx:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
	free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
out_free_rx:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
	free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
out_err:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
	return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
static void nv_free_irq(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
	if (np->msi_flags & NV_MSI_X_ENABLED) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
		for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
			free_irq(np->msi_x_entry[i].vector, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
		pci_disable_msix(np->pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
		np->msi_flags &= ~NV_MSI_X_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
		free_irq(np->pci_dev->irq, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
		if (np->msi_flags & NV_MSI_ENABLED) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
			pci_disable_msi(np->pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
			pci_intx(np->pci_dev, 1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
			np->msi_flags &= ~NV_MSI_ENABLED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
void ec_poll(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
{
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2911
	struct fe_priv *np = netdev_priv(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2912
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2913
	if (!using_multi_irqs(dev)) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2914
		nv_nic_irq(0, dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2915
	} else {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2916
		if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2917
			nv_nic_irq_rx(0, dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2918
		}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2919
		if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2920
			nv_nic_irq_tx(0, dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2921
		}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2922
		if (np->nic_poll_irq & NVREG_IRQ_OTHER) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2923
			nv_nic_irq_other(0, dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2924
		}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  2925
	}
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
static void nv_do_nic_poll(unsigned long data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
	u32 mask = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
	/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
	 * First disable irq(s) and then
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
	 * reenable interrupts on the nic, we have to do this before calling
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
	 * nv_nic_irq because that may decide to do otherwise
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	if (!using_multi_irqs(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
		if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
			disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
			disable_irq_lockdep(dev->irq);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
		mask = np->irqmask;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
		if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
			disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
			mask |= NVREG_IRQ_RX_ALL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
		if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
			disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
			mask |= NVREG_IRQ_TX_ALL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
		if (np->nic_poll_irq & NVREG_IRQ_OTHER) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
			disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
			mask |= NVREG_IRQ_OTHER;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
	np->nic_poll_irq = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
	/* FIXME: Do we need synchronize_irq(dev->irq) here? */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
	writel(mask, base + NvRegIrqMask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
	if (!using_multi_irqs(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
		nv_nic_irq(0, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		if (np->msi_flags & NV_MSI_X_ENABLED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
			enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
			enable_irq_lockdep(dev->irq);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
		if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
			nv_nic_irq_rx(0, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
			enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
		if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
			nv_nic_irq_tx(0, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
			enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
		if (np->nic_poll_irq & NVREG_IRQ_OTHER) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
			nv_nic_irq_other(0, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
			enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
#ifdef CONFIG_NET_POLL_CONTROLLER
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
static void nv_poll_controller(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
	nv_do_nic_poll((unsigned long) dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
static void nv_do_stats_poll(unsigned long data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
	struct net_device *dev = (struct net_device *) data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
	np->estats.tx_bytes += readl(base + NvRegTxCnt);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
	np->estats.tx_zero_rexmt += readl(base + NvRegTxZeroReXmt);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
	np->estats.tx_one_rexmt += readl(base + NvRegTxOneReXmt);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
	np->estats.tx_many_rexmt += readl(base + NvRegTxManyReXmt);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
	np->estats.tx_late_collision += readl(base + NvRegTxLateCol);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
	np->estats.tx_fifo_errors += readl(base + NvRegTxUnderflow);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
	np->estats.tx_carrier_errors += readl(base + NvRegTxLossCarrier);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
	np->estats.tx_excess_deferral += readl(base + NvRegTxExcessDef);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
	np->estats.tx_retry_error += readl(base + NvRegTxRetryErr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
	np->estats.tx_deferral += readl(base + NvRegTxDef);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
	np->estats.tx_packets += readl(base + NvRegTxFrame);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
	np->estats.tx_pause += readl(base + NvRegTxPause);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
	np->estats.rx_frame_error += readl(base + NvRegRxFrameErr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
	np->estats.rx_extra_byte += readl(base + NvRegRxExtraByte);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
	np->estats.rx_late_collision += readl(base + NvRegRxLateCol);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
	np->estats.rx_runt += readl(base + NvRegRxRunt);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
	np->estats.rx_frame_too_long += readl(base + NvRegRxFrameTooLong);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
	np->estats.rx_over_errors += readl(base + NvRegRxOverflow);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
	np->estats.rx_crc_errors += readl(base + NvRegRxFCSErr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
	np->estats.rx_frame_align_error += readl(base + NvRegRxFrameAlignErr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
	np->estats.rx_length_error += readl(base + NvRegRxLenErr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
	np->estats.rx_unicast += readl(base + NvRegRxUnicast);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
	np->estats.rx_multicast += readl(base + NvRegRxMulticast);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
	np->estats.rx_broadcast += readl(base + NvRegRxBroadcast);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
	np->estats.rx_bytes += readl(base + NvRegRxCnt);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
	np->estats.rx_pause += readl(base + NvRegRxPause);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
	np->estats.rx_drop_frame += readl(base + NvRegRxDropFrame);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
	np->estats.rx_packets =
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
		np->estats.rx_unicast +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
		np->estats.rx_multicast +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
		np->estats.rx_broadcast;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
	np->estats.rx_errors_total =
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
		np->estats.rx_crc_errors +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
		np->estats.rx_over_errors +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
		np->estats.rx_frame_error +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		(np->estats.rx_frame_align_error - np->estats.rx_extra_byte) +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
		np->estats.rx_late_collision +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		np->estats.rx_runt +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
		np->estats.rx_frame_too_long;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
	if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
		mod_timer(&np->stats_poll, jiffies + STATS_INTERVAL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
	strcpy(info->driver, "forcedeth");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
	strcpy(info->version, FORCEDETH_VERSION);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
	strcpy(info->bus_info, pci_name(np->pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
	wolinfo->supported = WAKE_MAGIC;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
	spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
	if (np->wolenabled)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
		wolinfo->wolopts = WAKE_MAGIC;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
	spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
	u32 flags = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
	if (wolinfo->wolopts == 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
		np->wolenabled = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
	} else if (wolinfo->wolopts & WAKE_MAGIC) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
		np->wolenabled = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
		flags = NVREG_WAKEUPFLAGS_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
		writel(flags, base + NvRegWakeUpFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
		spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
static int nv_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
	int adv;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
	spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
	ecmd->port = PORT_MII;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
	if (!netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
		/* We do not track link speed / duplex setting if the
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
		 * interface is disabled. Force a link check */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
		if (nv_update_linkspeed(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
			if (!netif_carrier_ok(dev))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
				netif_carrier_on(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
			if (netif_carrier_ok(dev))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
				netif_carrier_off(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
	if (netif_carrier_ok(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
		switch(np->linkspeed & (NVREG_LINKSPEED_MASK)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
		case NVREG_LINKSPEED_10:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
			ecmd->speed = SPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
		case NVREG_LINKSPEED_100:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
			ecmd->speed = SPEED_100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
		case NVREG_LINKSPEED_1000:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
			ecmd->speed = SPEED_1000;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
		ecmd->duplex = DUPLEX_HALF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
		if (np->duplex)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
			ecmd->duplex = DUPLEX_FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
		ecmd->speed = -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
		ecmd->duplex = -1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
	ecmd->autoneg = np->autoneg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
	ecmd->advertising = ADVERTISED_MII;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
	if (np->autoneg) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
		ecmd->advertising |= ADVERTISED_Autoneg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
		adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
		if (adv & ADVERTISE_10HALF)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
			ecmd->advertising |= ADVERTISED_10baseT_Half;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
		if (adv & ADVERTISE_10FULL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
			ecmd->advertising |= ADVERTISED_10baseT_Full;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
		if (adv & ADVERTISE_100HALF)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
			ecmd->advertising |= ADVERTISED_100baseT_Half;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
		if (adv & ADVERTISE_100FULL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
			ecmd->advertising |= ADVERTISED_100baseT_Full;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
		if (np->gigabit == PHY_GIGABIT) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
			adv = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
			if (adv & ADVERTISE_1000FULL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
				ecmd->advertising |= ADVERTISED_1000baseT_Full;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
	ecmd->supported = (SUPPORTED_Autoneg |
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
		SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
		SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
		SUPPORTED_MII);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
	if (np->gigabit == PHY_GIGABIT)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		ecmd->supported |= SUPPORTED_1000baseT_Full;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
	ecmd->phy_address = np->phyaddr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
	ecmd->transceiver = XCVR_EXTERNAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
	/* ignore maxtxpkt, maxrxpkt for now */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
	spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
	if (ecmd->port != PORT_MII)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
	if (ecmd->transceiver != XCVR_EXTERNAL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
	if (ecmd->phy_address != np->phyaddr) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
		/* TODO: support switching between multiple phys. Should be
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
		 * trivial, but not enabled due to lack of test hardware. */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
	if (ecmd->autoneg == AUTONEG_ENABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
		u32 mask;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
		mask = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
			  ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
		if (np->gigabit == PHY_GIGABIT)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
			mask |= ADVERTISED_1000baseT_Full;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
		if ((ecmd->advertising & mask) == 0)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
			return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
	} else if (ecmd->autoneg == AUTONEG_DISABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
		/* Note: autonegotiation disable, speed 1000 intentionally
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
		 * forbidden - noone should need that. */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
		if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
			return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
		if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
			return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
	netif_carrier_off(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
		nv_disable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
		netif_tx_lock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
		spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
		/* stop engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
		nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
		nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
		spin_unlock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
		netif_tx_unlock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
	if (ecmd->autoneg == AUTONEG_ENABLE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
		int adv, bmcr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
		np->autoneg = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
		/* advertise only what has been requested */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
		adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
		adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
		if (ecmd->advertising & ADVERTISED_10baseT_Half)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
			adv |= ADVERTISE_10HALF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
		if (ecmd->advertising & ADVERTISED_10baseT_Full)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
			adv |= ADVERTISE_10FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
		if (ecmd->advertising & ADVERTISED_100baseT_Half)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
			adv |= ADVERTISE_100HALF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
		if (ecmd->advertising & ADVERTISED_100baseT_Full)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
			adv |= ADVERTISE_100FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
		if (np->pause_flags & NV_PAUSEFRAME_RX_REQ)  /* for rx we set both advertisments but disable tx pause */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
			adv |=  ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
		if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
			adv |=  ADVERTISE_PAUSE_ASYM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
		mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
		if (np->gigabit == PHY_GIGABIT) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
			adv = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
			adv &= ~ADVERTISE_1000FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
			if (ecmd->advertising & ADVERTISED_1000baseT_Full)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
				adv |= ADVERTISE_1000FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
			mii_rw(dev, np->phyaddr, MII_CTRL1000, adv);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
		if (netif_running(dev))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
			printk(KERN_INFO "%s: link down.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
		bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
		if (np->phy_model == PHY_MODEL_MARVELL_E3016) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
			bmcr |= BMCR_ANENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
			/* reset the phy in order for settings to stick,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
			 * and cause autoneg to start */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
			if (phy_reset(dev, bmcr)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
				printk(KERN_INFO "%s: phy reset failed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
				return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
			bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
			mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
		int adv, bmcr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
		np->autoneg = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
		adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
		adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
		if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_HALF)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
			adv |= ADVERTISE_10HALF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
		if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_FULL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
			adv |= ADVERTISE_10FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
		if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_HALF)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
			adv |= ADVERTISE_100HALF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
		if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_FULL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
			adv |= ADVERTISE_100FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
		np->pause_flags &= ~(NV_PAUSEFRAME_AUTONEG|NV_PAUSEFRAME_RX_ENABLE|NV_PAUSEFRAME_TX_ENABLE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
		if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) {/* for rx we set both advertisments but disable tx pause */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
			adv |=  ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
			np->pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
		if (np->pause_flags & NV_PAUSEFRAME_TX_REQ) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
			adv |=  ADVERTISE_PAUSE_ASYM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
			np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
		mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
		np->fixed_mode = adv;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
		if (np->gigabit == PHY_GIGABIT) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
			adv = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
			adv &= ~ADVERTISE_1000FULL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
			mii_rw(dev, np->phyaddr, MII_CTRL1000, adv);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
		bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
		bmcr &= ~(BMCR_ANENABLE|BMCR_SPEED100|BMCR_SPEED1000|BMCR_FULLDPLX);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
		if (np->fixed_mode & (ADVERTISE_10FULL|ADVERTISE_100FULL))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
			bmcr |= BMCR_FULLDPLX;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
		if (np->fixed_mode & (ADVERTISE_100HALF|ADVERTISE_100FULL))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
			bmcr |= BMCR_SPEED100;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
		if (np->phy_oui == PHY_OUI_MARVELL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
			/* reset the phy in order for forced mode settings to stick */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
			if (phy_reset(dev, bmcr)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
				printk(KERN_INFO "%s: phy reset failed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
				return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
			mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
			if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
				/* Wait a bit and then reconfigure the nic. */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
				udelay(10);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
				nv_linkchange(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
		nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
		nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
		nv_enable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
#define FORCEDETH_REGS_VER	1
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
static int nv_get_regs_len(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
	return np->register_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
	u32 *rbuf = buf;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
	int i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
	regs->version = FORCEDETH_REGS_VER;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
	for (i = 0;i <= np->register_size/sizeof(u32); i++)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
		rbuf[i] = readl(base + i*sizeof(u32));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
	spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
static int nv_nway_reset(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
	int ret;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
	if (np->autoneg) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
		int bmcr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
		netif_carrier_off(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
		if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
			nv_disable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
			netif_tx_lock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
			spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
			/* stop engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
			nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
			nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
			spin_unlock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
			netif_tx_unlock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
			printk(KERN_INFO "%s: link down.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
		bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
		if (np->phy_model == PHY_MODEL_MARVELL_E3016) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
			bmcr |= BMCR_ANENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
			/* reset the phy in order for settings to stick*/
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
			if (phy_reset(dev, bmcr)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
				printk(KERN_INFO "%s: phy reset failed\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
				return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
			bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
			mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
		if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
			nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
			nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
			nv_enable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
		ret = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
		ret = -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
	return ret;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
static int nv_set_tso(struct net_device *dev, u32 value)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
	if ((np->driver_data & DEV_HAS_CHECKSUM))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
		return ethtool_op_set_tso(dev, value);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
		return -EOPNOTSUPP;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
static void nv_get_ringparam(struct net_device *dev, struct ethtool_ringparam* ring)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
	ring->rx_max_pending = (np->desc_ver == DESC_VER_1) ? RING_MAX_DESC_VER_1 : RING_MAX_DESC_VER_2_3;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	ring->rx_mini_max_pending = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
	ring->rx_jumbo_max_pending = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
	ring->tx_max_pending = (np->desc_ver == DESC_VER_1) ? RING_MAX_DESC_VER_1 : RING_MAX_DESC_VER_2_3;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
	ring->rx_pending = np->rx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
	ring->rx_mini_pending = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
	ring->rx_jumbo_pending = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
	ring->tx_pending = np->tx_ring_size;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ring)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
	u8 *rxtx_ring, *rx_skbuff, *tx_skbuff, *rx_dma, *tx_dma, *tx_dma_len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
	dma_addr_t ring_addr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
	if (ring->rx_pending < RX_RING_MIN ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
	    ring->tx_pending < TX_RING_MIN ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
	    ring->rx_mini_pending != 0 ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
	    ring->rx_jumbo_pending != 0 ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
	    (np->desc_ver == DESC_VER_1 &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
	     (ring->rx_pending > RING_MAX_DESC_VER_1 ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
	      ring->tx_pending > RING_MAX_DESC_VER_1)) ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
	    (np->desc_ver != DESC_VER_1 &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
	     (ring->rx_pending > RING_MAX_DESC_VER_2_3 ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
	      ring->tx_pending > RING_MAX_DESC_VER_2_3))) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
	/* allocate new rings */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
		rxtx_ring = pci_alloc_consistent(np->pci_dev,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
					    sizeof(struct ring_desc) * (ring->rx_pending + ring->tx_pending),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
					    &ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
		rxtx_ring = pci_alloc_consistent(np->pci_dev,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
					    sizeof(struct ring_desc_ex) * (ring->rx_pending + ring->tx_pending),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
					    &ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
	rx_skbuff = kmalloc(sizeof(struct sk_buff*) * ring->rx_pending, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
	rx_dma = kmalloc(sizeof(dma_addr_t) * ring->rx_pending, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
	tx_skbuff = kmalloc(sizeof(struct sk_buff*) * ring->tx_pending, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
	tx_dma = kmalloc(sizeof(dma_addr_t) * ring->tx_pending, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
	tx_dma_len = kmalloc(sizeof(unsigned int) * ring->tx_pending, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
	if (!rxtx_ring || !rx_skbuff || !rx_dma || !tx_skbuff || !tx_dma || !tx_dma_len) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
		/* fall back to old rings */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
			if (rxtx_ring)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
				pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (ring->rx_pending + ring->tx_pending),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
						    rxtx_ring, ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
			if (rxtx_ring)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
				pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (ring->rx_pending + ring->tx_pending),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
						    rxtx_ring, ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
		if (rx_skbuff)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
			kfree(rx_skbuff);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
		if (rx_dma)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
			kfree(rx_dma);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
		if (tx_skbuff)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
			kfree(tx_skbuff);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
		if (tx_dma)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
			kfree(tx_dma);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
		if (tx_dma_len)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
			kfree(tx_dma_len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
		goto exit;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
		nv_disable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
		netif_tx_lock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
		spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
		/* stop engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
		nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
		nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
		nv_txrx_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
		/* drain queues */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
		nv_drain_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
		nv_drain_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
		/* delete queues */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
		free_rings(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
	/* set new values */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
	np->rx_ring_size = ring->rx_pending;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
	np->tx_ring_size = ring->tx_pending;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
	np->tx_limit_stop = ring->tx_pending - TX_LIMIT_DIFFERENCE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	np->tx_limit_start = ring->tx_pending - TX_LIMIT_DIFFERENCE - 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
		np->rx_ring.orig = (struct ring_desc*)rxtx_ring;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
		np->tx_ring.orig = &np->rx_ring.orig[np->rx_ring_size];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
		np->rx_ring.ex = (struct ring_desc_ex*)rxtx_ring;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
		np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
	np->rx_skbuff = (struct sk_buff**)rx_skbuff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
	np->rx_dma = (dma_addr_t*)rx_dma;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
	np->tx_skbuff = (struct sk_buff**)tx_skbuff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
	np->tx_dma = (dma_addr_t*)tx_dma;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
	np->tx_dma_len = (unsigned int*)tx_dma_len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	np->ring_addr = ring_addr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
	memset(np->rx_skbuff, 0, sizeof(struct sk_buff*) * np->rx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
	memset(np->rx_dma, 0, sizeof(dma_addr_t) * np->rx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
	memset(np->tx_skbuff, 0, sizeof(struct sk_buff*) * np->tx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
	memset(np->tx_dma, 0, sizeof(dma_addr_t) * np->tx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
	memset(np->tx_dma_len, 0, sizeof(unsigned int) * np->tx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
		/* reinit driver view of the queues */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
		set_bufsize(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
		if (nv_init_ring(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
			if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
				mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
		/* reinit nic view of the queues */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
		writel(np->rx_buf_sz, base + NvRegOffloadConfig);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
		setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
		writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
			base + NvRegRingSizes);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
		writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
		pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
		/* restart engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
		nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
		nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
		spin_unlock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
		netif_tx_unlock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
		nv_enable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
exit:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
	return -ENOMEM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
static void nv_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam* pause)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
	pause->autoneg = (np->pause_flags & NV_PAUSEFRAME_AUTONEG) != 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
	pause->rx_pause = (np->pause_flags & NV_PAUSEFRAME_RX_ENABLE) != 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
	pause->tx_pause = (np->pause_flags & NV_PAUSEFRAME_TX_ENABLE) != 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
static int nv_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam* pause)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
	int adv, bmcr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
	if ((!np->autoneg && np->duplex == 0) ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
	    (np->autoneg && !pause->autoneg && np->duplex == 0)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
		printk(KERN_INFO "%s: can not set pause settings when forced link is in half duplex.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
		       dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
	if (pause->tx_pause && !(np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
		printk(KERN_INFO "%s: hardware does not support tx pause frames.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
	netif_carrier_off(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
		nv_disable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
		netif_tx_lock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
		spin_lock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
		/* stop engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
		nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
		nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
		spin_unlock(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
		netif_tx_unlock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
	np->pause_flags &= ~(NV_PAUSEFRAME_RX_REQ|NV_PAUSEFRAME_TX_REQ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
	if (pause->rx_pause)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
		np->pause_flags |= NV_PAUSEFRAME_RX_REQ;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
	if (pause->tx_pause)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
		np->pause_flags |= NV_PAUSEFRAME_TX_REQ;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
	if (np->autoneg && pause->autoneg) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
		np->pause_flags |= NV_PAUSEFRAME_AUTONEG;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
		adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
		adv &= ~(ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
		if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) /* for rx we set both advertisments but disable tx pause */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
			adv |=  ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
		if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
			adv |=  ADVERTISE_PAUSE_ASYM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
		mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
		if (netif_running(dev))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
			printk(KERN_INFO "%s: link down.\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
		bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
		bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
		mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
		np->pause_flags &= ~(NV_PAUSEFRAME_AUTONEG|NV_PAUSEFRAME_RX_ENABLE|NV_PAUSEFRAME_TX_ENABLE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
		if (pause->rx_pause)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
			np->pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
		if (pause->tx_pause)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
			np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
		if (!netif_running(dev))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
			nv_update_linkspeed(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
			nv_update_pause(dev, np->pause_flags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
		nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
		nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
		nv_enable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
static u32 nv_get_rx_csum(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
	return (np->rx_csum) != 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
static int nv_set_rx_csum(struct net_device *dev, u32 data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
	int retcode = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
	if (np->driver_data & DEV_HAS_CHECKSUM) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
		if (data) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
			np->rx_csum = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
			np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
			np->rx_csum = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
			/* vlan is dependent on rx checksum offload */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
			if (!(np->vlanctl_bits & NVREG_VLANCONTROL_ENABLE))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
				np->txrxctl_bits &= ~NVREG_TXRXCTL_RXCHECK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
		if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
			spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
			writel(np->txrxctl_bits, base + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
			spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
		return -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
	return retcode;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
static int nv_set_tx_csum(struct net_device *dev, u32 data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
	if (np->driver_data & DEV_HAS_CHECKSUM)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		return ethtool_op_set_tx_hw_csum(dev, data);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
		return -EOPNOTSUPP;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
static int nv_set_sg(struct net_device *dev, u32 data)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
	if (np->driver_data & DEV_HAS_CHECKSUM)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
		return ethtool_op_set_sg(dev, data);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
		return -EOPNOTSUPP;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
static int nv_get_stats_count(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
	if (np->driver_data & DEV_HAS_STATISTICS)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
		return sizeof(struct nv_ethtool_stats)/sizeof(u64);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
static void nv_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *estats, u64 *buffer)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
	/* update stats */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	nv_do_stats_poll((unsigned long)dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
	memcpy(buffer, &np->estats, nv_get_stats_count(dev)*sizeof(u64));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
static int nv_self_test_count(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
	if (np->driver_data & DEV_HAS_TEST_EXTENDED)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
		return NV_TEST_COUNT_EXTENDED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
		return NV_TEST_COUNT_BASE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
static int nv_link_test(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
	int mii_status;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
	mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
	/* check phy link status */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
	if (!(mii_status & BMSR_LSTATUS))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
		return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
static int nv_register_test(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
	int i = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	u32 orig_read, new_read;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
	do {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
		orig_read = readl(base + nv_registers_test[i].reg);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
		/* xor with mask to toggle bits */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
		orig_read ^= nv_registers_test[i].mask;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
		writel(orig_read, base + nv_registers_test[i].reg);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
		new_read = readl(base + nv_registers_test[i].reg);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
		if ((new_read & nv_registers_test[i].mask) != (orig_read & nv_registers_test[i].mask))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
			return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
		/* restore original value */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
		orig_read ^= nv_registers_test[i].mask;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
		writel(orig_read, base + nv_registers_test[i].reg);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
	} while (nv_registers_test[++i].reg != 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
	return 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
static int nv_interrupt_test(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
	int ret = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	int testcnt;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
	u32 save_msi_flags, save_poll_interval = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
		/* free current irq */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
		nv_free_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
		save_poll_interval = readl(base+NvRegPollingInterval);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	/* flag to test interrupt handler */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
	np->intr_test = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	/* setup test irq */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
	save_msi_flags = np->msi_flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
	np->msi_flags &= ~NV_MSI_X_VECTORS_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
	np->msi_flags |= 0x001; /* setup 1 vector */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
	if (nv_request_irq(dev, 1))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
		return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
	/* setup timer interrupt */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	writel(NVREG_POLL_DEFAULT_CPU, base + NvRegPollingInterval);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
	writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
	nv_enable_hw_interrupts(dev, NVREG_IRQ_TIMER);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	/* wait for at least one interrupt */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
	msleep(100);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
	/* flag should be set within ISR */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
	testcnt = np->intr_test;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
	if (!testcnt)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
		ret = 2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	nv_disable_hw_interrupts(dev, NVREG_IRQ_TIMER);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
	if (!(np->msi_flags & NV_MSI_X_ENABLED))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
		writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
		writel(NVREG_IRQSTAT_MASK, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
	spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
	nv_free_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
	np->msi_flags = save_msi_flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
		writel(save_poll_interval, base + NvRegPollingInterval);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
		writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
		/* restore original irq */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
		if (nv_request_irq(dev, 0))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
			return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
	return ret;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
static int nv_loopback_test(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
	struct sk_buff *tx_skb, *rx_skb;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
	dma_addr_t test_dma_addr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
	u32 tx_flags_extra = (np->desc_ver == DESC_VER_1 ? NV_TX_LASTPACKET : NV_TX2_LASTPACKET);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
	u32 flags;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
	int len, i, pkt_len;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
	u8 *pkt_data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
	u32 filter_flags = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
	u32 misc1_flags = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
	int ret = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
		nv_disable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
		filter_flags = readl(base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
		misc1_flags = readl(base + NvRegMisc1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
		nv_txrx_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
	/* reinit driver view of the rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	set_bufsize(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
	nv_init_ring(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
	/* setup hardware for loopback */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
	writel(NVREG_MISC1_FORCE, base + NvRegMisc1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
	writel(NVREG_PFF_ALWAYS | NVREG_PFF_LOOPBACK, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	/* reinit nic view of the rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
	writel(np->rx_buf_sz, base + NvRegOffloadConfig);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
	setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
		base + NvRegRingSizes);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	/* restart rx engine */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
	nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
	nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
	/* setup packet for tx */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
	pkt_len = ETH_DATA_LEN;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
	tx_skb = dev_alloc_skb(pkt_len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
	if (!tx_skb) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
		printk(KERN_ERR "dev_alloc_skb() failed during loopback test"
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
			 " of %s\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
		ret = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
		goto out;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
	pkt_data = skb_put(tx_skb, pkt_len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
	for (i = 0; i < pkt_len; i++)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
		pkt_data[i] = (u8)(i & 0xff);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
	test_dma_addr = pci_map_single(np->pci_dev, tx_skb->data,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
				       tx_skb->end-tx_skb->data, PCI_DMA_FROMDEVICE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
		np->tx_ring.orig[0].buf = cpu_to_le32(test_dma_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
		np->tx_ring.orig[0].flaglen = cpu_to_le32((pkt_len-1) | np->tx_flags | tx_flags_extra);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
		np->tx_ring.ex[0].bufhigh = cpu_to_le64(test_dma_addr) >> 32;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
		np->tx_ring.ex[0].buflow = cpu_to_le64(test_dma_addr) & 0x0FFFFFFFF;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
		np->tx_ring.ex[0].flaglen = cpu_to_le32((pkt_len-1) | np->tx_flags | tx_flags_extra);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
	writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
	pci_push(get_hwbase(dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
	msleep(500);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	/* check for rx of the packet */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
		flags = le32_to_cpu(np->rx_ring.orig[0].flaglen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
		len = nv_descr_getlength(&np->rx_ring.orig[0], np->desc_ver);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
		flags = le32_to_cpu(np->rx_ring.ex[0].flaglen);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
		len = nv_descr_getlength_ex(&np->rx_ring.ex[0], np->desc_ver);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
	if (flags & NV_RX_AVAIL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
		ret = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
	} else if (np->desc_ver == DESC_VER_1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
		if (flags & NV_RX_ERROR)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
			ret = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
		if (flags & NV_RX2_ERROR) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
			ret = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
	if (ret) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
		if (len != pkt_len) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
			ret = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
			dprintk(KERN_DEBUG "%s: loopback len mismatch %d vs %d\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
				dev->name, len, pkt_len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
		} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
			rx_skb = np->rx_skbuff[0];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
			for (i = 0; i < pkt_len; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
				if (rx_skb->data[i] != (u8)(i & 0xff)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
					ret = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
					dprintk(KERN_DEBUG "%s: loopback pattern check failed on byte %d\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
						dev->name, i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
					break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
				}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
		dprintk(KERN_DEBUG "%s: loopback - did not receive test packet\n", dev->name);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
	pci_unmap_page(np->pci_dev, test_dma_addr,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
		       tx_skb->end-tx_skb->data,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
		       PCI_DMA_TODEVICE);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
	dev_kfree_skb_any(tx_skb);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
 out:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
	/* stop engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
	nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
	nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
	nv_txrx_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
	/* drain rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
	nv_drain_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
	nv_drain_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
	if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
		writel(misc1_flags, base + NvRegMisc1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
		writel(filter_flags, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
		nv_enable_irq(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
	return ret;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64 *buffer)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
	int result;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
	memset(buffer, 0, nv_self_test_count(dev)*sizeof(u64));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
	if (!nv_link_test(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
		test->flags |= ETH_TEST_FL_FAILED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
		buffer[0] = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
	if (test->flags & ETH_TEST_FL_OFFLINE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
		if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
			netif_stop_queue(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
			netif_poll_disable(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
			netif_tx_lock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
			spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
			nv_disable_hw_interrupts(dev, np->irqmask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
			if (!(np->msi_flags & NV_MSI_X_ENABLED)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
				writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
			} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
				writel(NVREG_IRQSTAT_MASK, base + NvRegMSIXIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
			/* stop engines */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
			nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
			nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
			nv_txrx_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
			/* drain rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
			nv_drain_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
			nv_drain_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
			spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
			netif_tx_unlock_bh(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
		if (!nv_register_test(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
			test->flags |= ETH_TEST_FL_FAILED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
			buffer[1] = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
		result = nv_interrupt_test(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
		if (result != 1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
			test->flags |= ETH_TEST_FL_FAILED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
			buffer[2] = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
		if (result == 0) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
			/* bail out */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
			return;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
		if (!nv_loopback_test(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
			test->flags |= ETH_TEST_FL_FAILED;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
			buffer[3] = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
		if (netif_running(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
			/* reinit driver view of the rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
			set_bufsize(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
			if (nv_init_ring(dev)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
				if (!np->in_shutdown)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
					mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
			/* reinit nic view of the rx queue */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
			writel(np->rx_buf_sz, base + NvRegOffloadConfig);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
			setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
			writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
				base + NvRegRingSizes);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
			pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
			writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
			pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
			/* restart rx engine */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
			nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
			nv_start_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
			netif_start_queue(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
			netif_poll_enable(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
			nv_enable_hw_interrupts(dev, np->irqmask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
static void nv_get_strings(struct net_device *dev, u32 stringset, u8 *buffer)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
	switch (stringset) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
	case ETH_SS_STATS:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
		memcpy(buffer, &nv_estats_str, nv_get_stats_count(dev)*sizeof(struct nv_ethtool_str));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
		break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
	case ETH_SS_TEST:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
		memcpy(buffer, &nv_etests_str, nv_self_test_count(dev)*sizeof(struct nv_ethtool_str));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
		break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
static const struct ethtool_ops ops = {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
	.get_drvinfo = nv_get_drvinfo,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
	.get_link = ethtool_op_get_link,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
	.get_wol = nv_get_wol,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
	.set_wol = nv_set_wol,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
	.get_settings = nv_get_settings,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
	.set_settings = nv_set_settings,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
	.get_regs_len = nv_get_regs_len,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
	.get_regs = nv_get_regs,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
	.nway_reset = nv_nway_reset,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
	.get_perm_addr = ethtool_op_get_perm_addr,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
	.get_tso = ethtool_op_get_tso,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
	.set_tso = nv_set_tso,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
	.get_ringparam = nv_get_ringparam,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
	.set_ringparam = nv_set_ringparam,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
	.get_pauseparam = nv_get_pauseparam,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
	.set_pauseparam = nv_set_pauseparam,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
	.get_rx_csum = nv_get_rx_csum,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
	.set_rx_csum = nv_set_rx_csum,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
	.get_tx_csum = ethtool_op_get_tx_csum,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
	.set_tx_csum = nv_set_tx_csum,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
	.get_sg = ethtool_op_get_sg,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
	.set_sg = nv_set_sg,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
	.get_strings = nv_get_strings,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
	.get_stats_count = nv_get_stats_count,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
	.get_ethtool_stats = nv_get_ethtool_stats,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
	.self_test_count = nv_self_test_count,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
	.self_test = nv_self_test,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
static void nv_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
	struct fe_priv *np = get_nvpriv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
	spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
	/* save vlan group */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
	np->vlangrp = grp;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
	if (grp) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
		/* enable vlan on MAC */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
		np->txrxctl_bits |= NVREG_TXRXCTL_VLANSTRIP | NVREG_TXRXCTL_VLANINS;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
		/* disable vlan on MAC */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
		np->txrxctl_bits &= ~NVREG_TXRXCTL_VLANSTRIP;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
		np->txrxctl_bits &= ~NVREG_TXRXCTL_VLANINS;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
	writel(np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
	spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
static void nv_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
	/* nothing to do */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
static int nv_open(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
	int ret = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
	int oom, i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
	dprintk(KERN_DEBUG "nv_open: begin\n");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
	/* erase previous misconfiguration */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
	if (np->driver_data & DEV_HAS_POWER_CNTRL)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
		nv_mac_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
	writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
	writel(0, base + NvRegMulticastAddrB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
	writel(0, base + NvRegMulticastMaskA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
	writel(0, base + NvRegMulticastMaskB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
	writel(0, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
	writel(0, base + NvRegTransmitterControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
	writel(0, base + NvRegReceiverControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
	writel(0, base + NvRegAdapterControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
	if (np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
		writel(NVREG_TX_PAUSEFRAME_DISABLE,  base + NvRegTxPauseFrame);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
	/* initialize descriptor rings */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
	set_bufsize(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
	oom = nv_init_ring(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
	writel(0, base + NvRegLinkSpeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
	writel(readl(base + NvRegTransmitPoll) & NVREG_TRANSMITPOLL_MAC_ADDR_REV, base + NvRegTransmitPoll);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
	nv_txrx_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
	writel(0, base + NvRegUnknownSetupReg6);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
	np->in_shutdown = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
	/* give hw rings */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
	setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
	writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
		base + NvRegRingSizes);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
	writel(np->linkspeed, base + NvRegLinkSpeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
	if (np->desc_ver == DESC_VER_1)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
		writel(NVREG_TX_WM_DESC1_DEFAULT, base + NvRegTxWatermark);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
		writel(NVREG_TX_WM_DESC2_3_DEFAULT, base + NvRegTxWatermark);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
	writel(np->txrxctl_bits, base + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
	writel(np->vlanctl_bits, base + NvRegVlanControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
	writel(NVREG_TXRXCTL_BIT1|np->txrxctl_bits, base + NvRegTxRxControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
	reg_delay(dev, NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP5_BIT31,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
			NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
			KERN_INFO "open: SetupReg5, Bit 31 remained off\n");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
	writel(0, base + NvRegUnknownSetupReg4);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
	writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
	writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
	writel(NVREG_MISC1_FORCE | NVREG_MISC1_HD, base + NvRegMisc1);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
	writel(readl(base + NvRegTransmitterStatus), base + NvRegTransmitterStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
	writel(NVREG_PFF_ALWAYS, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
	writel(np->rx_buf_sz, base + NvRegOffloadConfig);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
	writel(readl(base + NvRegReceiverStatus), base + NvRegReceiverStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
	get_random_bytes(&i, sizeof(i));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
	writel(NVREG_RNDSEED_FORCE | (i&NVREG_RNDSEED_MASK), base + NvRegRandomSeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
	writel(NVREG_TX_DEFERRAL_DEFAULT, base + NvRegTxDeferral);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
	writel(NVREG_RX_DEFERRAL_DEFAULT, base + NvRegRxDeferral);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
	if (poll_interval == -1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
		if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
			writel(NVREG_POLL_DEFAULT_THROUGHPUT, base + NvRegPollingInterval);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
		else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
			writel(NVREG_POLL_DEFAULT_CPU, base + NvRegPollingInterval);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
		writel(poll_interval & 0xFFFF, base + NvRegPollingInterval);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
	writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
	writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
			base + NvRegAdapterControl);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
	writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
	writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
	if (np->wolenabled)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
		writel(NVREG_WAKEUPFLAGS_ENABLE , base + NvRegWakeUpFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
	i = readl(base + NvRegPowerState);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	if ( (i & NVREG_POWERSTATE_POWEREDUP) == 0)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
		writel(NVREG_POWERSTATE_POWEREDUP|i, base + NvRegPowerState);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
	udelay(10);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
	writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID, base + NvRegPowerState);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
	nv_disable_hw_interrupts(dev, np->irqmask);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
	writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
	writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
	pci_push(base);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4190
	if (!np->ecdev) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4191
		if (nv_request_irq(dev, 0)) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4192
			goto out_drain;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4193
		}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4194
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4195
		/* ask for interrupts */
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4196
		nv_enable_hw_interrupts(dev, np->irqmask);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4197
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4198
		spin_lock_irq(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4199
	}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4200
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
	writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
	writel(0, base + NvRegMulticastAddrB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
	writel(0, base + NvRegMulticastMaskA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
	writel(0, base + NvRegMulticastMaskB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
	writel(NVREG_PFF_ALWAYS|NVREG_PFF_MYADDR, base + NvRegPacketFilterFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
	/* One manual link speed update: Interrupts are enabled, future link
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
	 * speed changes cause interrupts and are handled by nv_link_irq().
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
	{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
		u32 miistat;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
		miistat = readl(base + NvRegMIIStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
		writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
		dprintk(KERN_INFO "startup: got 0x%08x.\n", miistat);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
	/* set linkspeed to invalid value, thus force nv_update_linkspeed
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
	 * to init hw */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
	np->linkspeed = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
	ret = nv_update_linkspeed(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
	nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
	nv_start_tx(dev);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4221
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4222
	if (np->ecdev) {
670
f57de4585a5f Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
  4223
		ecdev_set_link(np->ecdev, ret);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4224
	}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4225
	else {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4226
		netif_start_queue(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4227
		netif_poll_enable(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4228
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4229
		if (ret) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4230
			netif_carrier_on(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4231
		} else {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4232
			printk("%s: no link during initialization.\n", dev->name);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4233
			netif_carrier_off(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4234
		}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4235
		if (oom)
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4236
			mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4237
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4238
		/* start statistics timer */
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4239
		if (np->driver_data & DEV_HAS_STATISTICS)
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4240
			mod_timer(&np->stats_poll, jiffies + STATS_INTERVAL);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4241
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4242
		spin_unlock_irq(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4243
	}
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
out_drain:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
	drain_ring(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
	return ret;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
static int nv_close(struct net_device *dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
	u8 __iomem *base;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4256
	if (!np->ecdev) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4257
		spin_lock_irq(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4258
		np->in_shutdown = 1;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4259
		spin_unlock_irq(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4260
		netif_poll_disable(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4261
		synchronize_irq(dev->irq);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4262
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4263
		del_timer_sync(&np->oom_kick);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4264
		del_timer_sync(&np->nic_poll);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4265
		del_timer_sync(&np->stats_poll);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4266
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4267
		netif_stop_queue(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4268
		spin_lock_irq(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4269
	}
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4270
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
	nv_stop_tx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
	nv_stop_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
	nv_txrx_reset(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
	/* disable interrupts on the nic or we will lock up */
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4276
	if (!np->ecdev) {
593
78c838980258 Minor fix in 2.6.19 forcedeth driver.
Florian Pose <fp@igh-essen.com>
parents: 591
diff changeset
  4277
		base = get_hwbase(dev);
78c838980258 Minor fix in 2.6.19 forcedeth driver.
Florian Pose <fp@igh-essen.com>
parents: 591
diff changeset
  4278
		nv_disable_hw_interrupts(dev, np->irqmask);
78c838980258 Minor fix in 2.6.19 forcedeth driver.
Florian Pose <fp@igh-essen.com>
parents: 591
diff changeset
  4279
		pci_push(base);
78c838980258 Minor fix in 2.6.19 forcedeth driver.
Florian Pose <fp@igh-essen.com>
parents: 591
diff changeset
  4280
		dprintk(KERN_INFO "%s: Irqmask is zero again\n", dev->name);
78c838980258 Minor fix in 2.6.19 forcedeth driver.
Florian Pose <fp@igh-essen.com>
parents: 591
diff changeset
  4281
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4282
		spin_unlock_irq(&np->lock);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4283
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4284
		nv_free_irq(dev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4285
	}
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
	drain_ring(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
	if (np->wolenabled)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
		nv_start_rx(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
	/* FIXME: power down nic */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
	struct net_device *dev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
	struct fe_priv *np;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
	unsigned long addr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
	u8 __iomem *base;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
	int err, i;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
	u32 powerstate, txreg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
    board_idx++;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
	dev = alloc_etherdev(sizeof(struct fe_priv));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
	err = -ENOMEM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
	if (!dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
		goto out;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
	np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
	np->pci_dev = pci_dev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
	spin_lock_init(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
	SET_MODULE_OWNER(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
	SET_NETDEV_DEV(dev, &pci_dev->dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
	init_timer(&np->oom_kick);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
	np->oom_kick.data = (unsigned long) dev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
	np->oom_kick.function = &nv_do_rx_refill;	/* timer handler */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
	init_timer(&np->nic_poll);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
	np->nic_poll.data = (unsigned long) dev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
	np->nic_poll.function = &nv_do_nic_poll;	/* timer handler */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
	init_timer(&np->stats_poll);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
	np->stats_poll.data = (unsigned long) dev;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
	np->stats_poll.function = &nv_do_stats_poll;	/* timer handler */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
	err = pci_enable_device(pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
	if (err) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
		printk(KERN_INFO "forcedeth: pci_enable_dev failed (%d) for device %s\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
				err, pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
		goto out_free;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
	pci_set_master(pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
	err = pci_request_regions(pci_dev, DRV_NAME);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
	if (err < 0)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
		goto out_disable;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
	if (id->driver_data & (DEV_HAS_VLAN|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_STATISTICS))
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
		np->register_size = NV_PCI_REGSZ_VER2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
	else
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
		np->register_size = NV_PCI_REGSZ_VER1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
	err = -EINVAL;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
	addr = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
		dprintk(KERN_DEBUG "%s: resource %d start %p len %ld flags 0x%08lx.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
				pci_name(pci_dev), i, (void*)pci_resource_start(pci_dev, i),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
				pci_resource_len(pci_dev, i),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
				pci_resource_flags(pci_dev, i));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
		if (pci_resource_flags(pci_dev, i) & IORESOURCE_MEM &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
				pci_resource_len(pci_dev, i) >= np->register_size) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
			addr = pci_resource_start(pci_dev, i);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
			break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
	if (i == DEVICE_COUNT_RESOURCE) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
		printk(KERN_INFO "forcedeth: Couldn't find register window for device %s.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
					pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
		goto out_relreg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
	/* copy of driver data */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
	np->driver_data = id->driver_data;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
	/* handle different descriptor versions */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
	if (id->driver_data & DEV_HAS_HIGH_DMA) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
		/* packet format 3: supports 40-bit addressing */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
		np->desc_ver = DESC_VER_3;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
		np->txrxctl_bits = NVREG_TXRXCTL_DESC_3;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
		if (dma_64bit) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
			if (pci_set_dma_mask(pci_dev, DMA_39BIT_MASK)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
				printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
				       pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
			} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
				dev->features |= NETIF_F_HIGHDMA;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
				printk(KERN_INFO "forcedeth: using HIGHDMA\n");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
			if (pci_set_consistent_dma_mask(pci_dev, DMA_39BIT_MASK)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
				printk(KERN_INFO "forcedeth: 64-bit DMA (consistent) failed, using 32-bit ring buffers for device %s.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
				       pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
			}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
	} else if (id->driver_data & DEV_HAS_LARGEDESC) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
		/* packet format 2: supports jumbo frames */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
		np->desc_ver = DESC_VER_2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
		np->txrxctl_bits = NVREG_TXRXCTL_DESC_2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
		/* original packet format */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
		np->desc_ver = DESC_VER_1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
		np->txrxctl_bits = NVREG_TXRXCTL_DESC_1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
	np->pkt_limit = NV_PKTLIMIT_1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
	if (id->driver_data & DEV_HAS_LARGEDESC)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
		np->pkt_limit = NV_PKTLIMIT_2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
	if (id->driver_data & DEV_HAS_CHECKSUM) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
		np->rx_csum = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
		np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
		dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
#ifdef NETIF_F_TSO
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
		dev->features |= NETIF_F_TSO;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
 	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
	np->vlanctl_bits = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
	if (id->driver_data & DEV_HAS_VLAN) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
		np->vlanctl_bits = NVREG_VLANCONTROL_ENABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
		dev->features |= NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
		dev->vlan_rx_register = nv_vlan_rx_register;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
		dev->vlan_rx_kill_vid = nv_vlan_rx_kill_vid;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
	np->msi_flags = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
	if ((id->driver_data & DEV_HAS_MSI) && msi) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
		np->msi_flags |= NV_MSI_CAPABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
	if ((id->driver_data & DEV_HAS_MSI_X) && msix) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
		np->msi_flags |= NV_MSI_X_CAPABLE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
	np->pause_flags = NV_PAUSEFRAME_RX_CAPABLE | NV_PAUSEFRAME_RX_REQ | NV_PAUSEFRAME_AUTONEG;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
	if (id->driver_data & DEV_HAS_PAUSEFRAME_TX) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
		np->pause_flags |= NV_PAUSEFRAME_TX_CAPABLE | NV_PAUSEFRAME_TX_REQ;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
	err = -ENOMEM;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
	np->base = ioremap(addr, np->register_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
	if (!np->base)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
		goto out_relreg;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
	dev->base_addr = (unsigned long)np->base;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
	dev->irq = pci_dev->irq;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
	np->rx_ring_size = RX_RING_DEFAULT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
	np->tx_ring_size = TX_RING_DEFAULT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
	np->tx_limit_stop = np->tx_ring_size - TX_LIMIT_DIFFERENCE;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
	np->tx_limit_start = np->tx_ring_size - TX_LIMIT_DIFFERENCE - 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
	if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
		np->rx_ring.orig = pci_alloc_consistent(pci_dev,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
					sizeof(struct ring_desc) * (np->rx_ring_size + np->tx_ring_size),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
					&np->ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
		if (!np->rx_ring.orig)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
			goto out_unmap;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
		np->tx_ring.orig = &np->rx_ring.orig[np->rx_ring_size];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
		np->rx_ring.ex = pci_alloc_consistent(pci_dev,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
					sizeof(struct ring_desc_ex) * (np->rx_ring_size + np->tx_ring_size),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
					&np->ring_addr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
		if (!np->rx_ring.ex)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
			goto out_unmap;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
		np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size];
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
	np->rx_skbuff = kmalloc(sizeof(struct sk_buff*) * np->rx_ring_size, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
	np->rx_dma = kmalloc(sizeof(dma_addr_t) * np->rx_ring_size, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
	np->tx_skbuff = kmalloc(sizeof(struct sk_buff*) * np->tx_ring_size, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
	np->tx_dma = kmalloc(sizeof(dma_addr_t) * np->tx_ring_size, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
	np->tx_dma_len = kmalloc(sizeof(unsigned int) * np->tx_ring_size, GFP_KERNEL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
	if (!np->rx_skbuff || !np->rx_dma || !np->tx_skbuff || !np->tx_dma || !np->tx_dma_len)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
		goto out_freering;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
	memset(np->rx_skbuff, 0, sizeof(struct sk_buff*) * np->rx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
	memset(np->rx_dma, 0, sizeof(dma_addr_t) * np->rx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
	memset(np->tx_skbuff, 0, sizeof(struct sk_buff*) * np->tx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
	memset(np->tx_dma, 0, sizeof(dma_addr_t) * np->tx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
	memset(np->tx_dma_len, 0, sizeof(unsigned int) * np->tx_ring_size);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
	dev->open = nv_open;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
	dev->stop = nv_close;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
	dev->hard_start_xmit = nv_start_xmit;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
	dev->get_stats = nv_get_stats;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
	dev->change_mtu = nv_change_mtu;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
	dev->set_mac_address = nv_set_mac_address;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
	dev->set_multicast_list = nv_set_multicast;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
#ifdef CONFIG_NET_POLL_CONTROLLER
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
	dev->poll_controller = nv_poll_controller;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
	dev->weight = 64;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
#ifdef CONFIG_FORCEDETH_NAPI
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
	dev->poll = nv_napi_poll;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
#endif
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
	SET_ETHTOOL_OPS(dev, &ops);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
	dev->tx_timeout = nv_tx_timeout;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
	dev->watchdog_timeo = NV_WATCHDOG_TIMEO;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
	pci_set_drvdata(pci_dev, dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
	/* read the mac address */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
	base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
	np->orig_mac[0] = readl(base + NvRegMacAddrA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
	np->orig_mac[1] = readl(base + NvRegMacAddrB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
	/* check the workaround bit for correct mac address order */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
	txreg = readl(base + NvRegTransmitPoll);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
	if (txreg & NVREG_TRANSMITPOLL_MAC_ADDR_REV) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
		/* mac address is already in correct order */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
		dev->dev_addr[0] = (np->orig_mac[0] >>  0) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
		dev->dev_addr[1] = (np->orig_mac[0] >>  8) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
		dev->dev_addr[2] = (np->orig_mac[0] >> 16) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
		dev->dev_addr[3] = (np->orig_mac[0] >> 24) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
		dev->dev_addr[4] = (np->orig_mac[1] >>  0) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
		dev->dev_addr[5] = (np->orig_mac[1] >>  8) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
		/* need to reverse mac address to correct order */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
		dev->dev_addr[0] = (np->orig_mac[1] >>  8) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
		dev->dev_addr[1] = (np->orig_mac[1] >>  0) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
		dev->dev_addr[2] = (np->orig_mac[0] >> 24) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
		dev->dev_addr[3] = (np->orig_mac[0] >> 16) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
		dev->dev_addr[4] = (np->orig_mac[0] >>  8) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
		dev->dev_addr[5] = (np->orig_mac[0] >>  0) & 0xff;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
		/* set permanent address to be correct aswell */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
		np->orig_mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) +
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
			(dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
		np->orig_mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
		writel(txreg|NVREG_TRANSMITPOLL_MAC_ADDR_REV, base + NvRegTransmitPoll);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
	if (!is_valid_ether_addr(dev->perm_addr)) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
		/*
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
		 * Bad mac address. At least one bios sets the mac address
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
		 * to 01:23:45:67:89:ab
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
		 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
		printk(KERN_ERR "%s: Invalid Mac address detected: %02x:%02x:%02x:%02x:%02x:%02x\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
			pci_name(pci_dev),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
			dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
			dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
		printk(KERN_ERR "Please complain to your hardware vendor. Switching to a random MAC.\n");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
		dev->dev_addr[0] = 0x00;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
		dev->dev_addr[1] = 0x00;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
		dev->dev_addr[2] = 0x6c;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
		get_random_bytes(&dev->dev_addr[3], 3);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
	dprintk(KERN_DEBUG "%s: MAC Address %02x:%02x:%02x:%02x:%02x:%02x\n", pci_name(pci_dev),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
			dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
			dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
	/* set mac address */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
	nv_copy_mac_to_hw(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
	/* disable WOL */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
	writel(0, base + NvRegWakeUpFlags);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
	np->wolenabled = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
	if (id->driver_data & DEV_HAS_POWER_CNTRL) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
		u8 revision_id;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
		pci_read_config_byte(pci_dev, PCI_REVISION_ID, &revision_id);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
		/* take phy and nic out of low power mode */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
		powerstate = readl(base + NvRegPowerState2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
		powerstate &= ~NVREG_POWERSTATE2_POWERUP_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
		if ((id->device == PCI_DEVICE_ID_NVIDIA_NVENET_12 ||
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
		     id->device == PCI_DEVICE_ID_NVIDIA_NVENET_13) &&
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
		    revision_id >= 0xA3)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
			powerstate |= NVREG_POWERSTATE2_POWERUP_REV_A3;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
		writel(powerstate, base + NvRegPowerState2);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
	if (np->desc_ver == DESC_VER_1) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
		np->tx_flags = NV_TX_VALID;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
		np->tx_flags = NV_TX2_VALID;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
	if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
		np->irqmask = NVREG_IRQMASK_THROUGHPUT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
		if (np->msi_flags & NV_MSI_X_CAPABLE) /* set number of vectors */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
			np->msi_flags |= 0x0003;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
		np->irqmask = NVREG_IRQMASK_CPU;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
		if (np->msi_flags & NV_MSI_X_CAPABLE) /* set number of vectors */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
			np->msi_flags |= 0x0001;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
	if (id->driver_data & DEV_NEED_TIMERIRQ)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
		np->irqmask |= NVREG_IRQ_TIMER;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
	if (id->driver_data & DEV_NEED_LINKTIMER) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
		dprintk(KERN_INFO "%s: link timer on.\n", pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
		np->need_linktimer = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
		np->link_timeout = jiffies + LINK_TIMEOUT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
	} else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
		dprintk(KERN_INFO "%s: link timer off.\n", pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
		np->need_linktimer = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
	/* find a suitable phy */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
	for (i = 1; i <= 32; i++) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
		int id1, id2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
		int phyaddr = i & 0x1F;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
		id1 = mii_rw(dev, phyaddr, MII_PHYSID1, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
		spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
		if (id1 < 0 || id1 == 0xffff)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
			continue;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
		spin_lock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
		id2 = mii_rw(dev, phyaddr, MII_PHYSID2, MII_READ);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
		spin_unlock_irq(&np->lock);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
		if (id2 < 0 || id2 == 0xffff)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
			continue;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
		np->phy_model = id2 & PHYID2_MODEL_MASK;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
		id1 = (id1 & PHYID1_OUI_MASK) << PHYID1_OUI_SHFT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
		id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
		dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
			pci_name(pci_dev), id1, id2, phyaddr);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
		np->phyaddr = phyaddr;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
		np->phy_oui = id1 | id2;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
		break;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
	if (i == 33) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
		printk(KERN_INFO "%s: open: Could not find a valid PHY.\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
		       pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
		goto out_error;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
	/* reset it */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
	phy_init(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
	/* set default link speed settings */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
	np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
	np->duplex = 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
	np->autoneg = 1;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
	// offer device to EtherCAT master module
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 670
diff changeset
  4631
	np->ecdev = ecdev_offer(dev, ec_poll, THIS_MODULE);
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4632
	if (np->ecdev) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4633
		if (ecdev_open(np->ecdev)) {
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4634
			ecdev_withdraw(np->ecdev);
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4635
			goto out_error;
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4636
		}
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 670
diff changeset
  4637
	} else {
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
		err = register_netdev(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
		if (err) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
			printk(KERN_INFO "forcedeth: unable to register netdev: %d\n", err);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
			goto out_freering;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
		}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
	printk(KERN_INFO "%s: forcedeth.c: subsystem: %05x:%04x bound to %s\n",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
			dev->name, pci_dev->subsystem_vendor, pci_dev->subsystem_device,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
			pci_name(pci_dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
	return 0;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
out_error:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
	pci_set_drvdata(pci_dev, NULL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
out_freering:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
	free_rings(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
out_unmap:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
	iounmap(get_hwbase(dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
out_relreg:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
	pci_release_regions(pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
out_disable:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
	pci_disable_device(pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
out_free:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
	free_netdev(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
out:
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
	return err;
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
static void __devexit nv_remove(struct pci_dev *pci_dev)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
	struct net_device *dev = pci_get_drvdata(pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
	struct fe_priv *np = netdev_priv(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
	u8 __iomem *base = get_hwbase(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
	if (np->ecdev) {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
		ecdev_close(np->ecdev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
		ecdev_withdraw(np->ecdev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
	else {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
		unregister_netdev(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
	}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
	/* special op: write back the misordered MAC address - otherwise
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
	 * the next nv_probe would see a wrong address.
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
	 */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
	writel(np->orig_mac[0], base + NvRegMacAddrA);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
	writel(np->orig_mac[1], base + NvRegMacAddrB);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
	/* free all structures */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	free_rings(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
	iounmap(get_hwbase(dev));
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
	pci_release_regions(pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
	pci_disable_device(pci_dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
	free_netdev(dev);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
	pci_set_drvdata(pci_dev, NULL);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
static struct pci_device_id pci_tbl[] = {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
	{	/* nForce Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_1),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
	{	/* nForce2 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_2),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
	{	/* nForce3 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_3),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
	{	/* nForce3 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_4),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
	{	/* nForce3 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_5),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
	{	/* nForce3 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_6),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
	{	/* nForce3 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_7),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
	{	/* CK804 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_8),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
	{	/* CK804 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_9),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
	{	/* MCP04 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_10),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
	{	/* MCP04 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_11),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
	{	/* MCP51 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
	{	/* MCP51 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_13),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
	{	/* MCP55 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
	{	/* MCP55 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
	{	/* MCP61 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
	{	/* MCP61 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
	{	/* MCP61 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
	{	/* MCP61 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
	{	/* MCP65 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
	{	/* MCP65 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
	{	/* MCP65 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
	{	/* MCP65 Ethernet Controller */
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
		PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
		.driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
	},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
	{0,},
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
static struct pci_driver driver = {
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
	.name = "forcedeth",
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
	.id_table = pci_tbl,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
	.probe = nv_probe,
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
	.remove = __devexit_p(nv_remove),
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
};
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
static int __init init_nic(void)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
{
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4801
	printk(KERN_INFO "forcedeth: EtherCAT-capable nForce ethernet driver."
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4802
			" Version %s, master %s.\n",
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4803
            FORCEDETH_VERSION, EC_MASTER_VERSION);
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
	return pci_register_driver(&driver);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
static void __exit exit_nic(void)
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
{
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
	pci_unregister_driver(&driver);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
}
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
module_param(max_interrupt_work, int, 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
MODULE_PARM_DESC(max_interrupt_work, "forcedeth maximum events handled per interrupt");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
module_param(optimization_mode, int, 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
MODULE_PARM_DESC(optimization_mode, "In throughput mode (0), every tx & rx packet will generate an interrupt. In CPU mode (1), interrupts are controlled by a timer.");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
module_param(poll_interval, int, 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
MODULE_PARM_DESC(poll_interval, "Interval determines how frequent timer interrupt is generated by [(time_in_micro_secs * 100) / (2^10)]. Min is 0 and Max is 65535.");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
module_param(msi, int, 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
MODULE_PARM_DESC(msi, "MSI interrupts are enabled by setting to 1 and disabled by setting to 0.");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
module_param(msix, int, 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
MODULE_PARM_DESC(msix, "MSIX interrupts are enabled by setting to 1 and disabled by setting to 0.");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
module_param(dma_64bit, int, 0);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
MODULE_PARM_DESC(dma_64bit, "High DMA is enabled by setting to 1 and disabled by setting to 0.");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
591
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4825
MODULE_AUTHOR("Dipl.-Ing. (FH) Florian Pose <fp@igh-essen.com>");
2b949dcba32b forcedeth device driver running fine.
Florian Pose <fp@igh-essen.com>
parents: 586
diff changeset
  4826
MODULE_DESCRIPTION("EtherCAT-capable nForce ethernet driver");
583
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
MODULE_LICENSE("GPL");
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
//MODULE_DEVICE_TABLE(pci, pci_tbl); // prevent auto-loading
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
module_init(init_nic);
172d42146930 Added testing version for forcedeth for 2.6.19 kernel.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
module_exit(exit_nic);