ia64/xen-unstable

changeset 173:5669423b1d2a

bitkeeper revision 1.39 (3e4d27e05zcnRwImrI-d9Wwi2axQLg)

network.c, dev.c, smp.h, e1000_osdep.h, Makefile:
Minor cleanups to network code.
.del-8139cp.c~52a760252927c3e8:
Delete: xen-2.4.16/drivers/net/8139cp.c
.del-eepro100.c~a29abf1c46dbaa08:
Delete: xen-2.4.16/drivers/net/eepro100.c
.del-pcnet32.c~7c61ad8be47473e4:
Delete: xen-2.4.16/drivers/net/pcnet32.c
.del-.depend~6dcd8dfbf6773eeb:
Delete: xen-2.4.16/drivers/net/tulip/.depend
.del-tulip_core.c~80117514fcabac13:
Delete: xen-2.4.16/drivers/net/tulip/tulip_core.c
.del-tulip.h~54606639dd5b212e:
Delete: xen-2.4.16/drivers/net/tulip/tulip.h
.del-timer.c~56eb96781641c48f:
Delete: xen-2.4.16/drivers/net/tulip/timer.c
.del-pnic2.c~cc9e8fae127ab7c4:
Delete: xen-2.4.16/drivers/net/tulip/pnic2.c
.del-pnic.c~4e4579265b47c3b6:
Delete: xen-2.4.16/drivers/net/tulip/pnic.c
.del-media.c~5b3d5b7b7749ae09:
Delete: xen-2.4.16/drivers/net/tulip/media.c
.del-interrupt.c~3a02cdd4ea7dfca7:
Delete: xen-2.4.16/drivers/net/tulip/interrupt.c
.del-eeprom.c~5662bb4a831735:
Delete: xen-2.4.16/drivers/net/tulip/eeprom.c
.del-Makefile~67195a81ff533a91:
Delete: xen-2.4.16/drivers/net/tulip/Makefile
.del-ChangeLog~48ee537632ad6a0:
Delete: xen-2.4.16/drivers/net/tulip/ChangeLog
.del-21142.c~b87c3c8b27ab44ba:
Delete: xen-2.4.16/drivers/net/tulip/21142.c
author kaf24@labyrinth.cl.cam.ac.uk
date Fri Feb 14 17:31:12 2003 +0000 (2003-02-14)
parents 9713c0d10ee7
children e98e082295e9
files .rootkeys xen-2.4.16/drivers/net/8139cp.c xen-2.4.16/drivers/net/Makefile xen-2.4.16/drivers/net/e1000/e1000_osdep.h xen-2.4.16/drivers/net/eepro100.c xen-2.4.16/drivers/net/pcnet32.c xen-2.4.16/drivers/net/tulip/.depend xen-2.4.16/drivers/net/tulip/21142.c xen-2.4.16/drivers/net/tulip/ChangeLog xen-2.4.16/drivers/net/tulip/Makefile xen-2.4.16/drivers/net/tulip/eeprom.c xen-2.4.16/drivers/net/tulip/interrupt.c xen-2.4.16/drivers/net/tulip/media.c xen-2.4.16/drivers/net/tulip/pnic.c xen-2.4.16/drivers/net/tulip/pnic2.c xen-2.4.16/drivers/net/tulip/timer.c xen-2.4.16/drivers/net/tulip/tulip.h xen-2.4.16/drivers/net/tulip/tulip_core.c xen-2.4.16/include/asm-i386/smp.h xen-2.4.16/net/dev.c xenolinux-2.4.16-sparse/arch/xeno/drivers/network/network.c
line diff
     1.1 --- a/.rootkeys	Fri Feb 14 17:11:31 2003 +0000
     1.2 +++ b/.rootkeys	Fri Feb 14 17:31:12 2003 +0000
     1.3 @@ -88,7 +88,6 @@ 3ddb79bdkDY1bSOYkToP1Cc49VdBxg xen-2.4.1
     1.4  3ddb79bdPyAvT_WZTAFhaX0jp-yXSw xen-2.4.16/drivers/ide/ide_modes.h
     1.5  3e4a8d401aSwOzCScQXR3lsmNlAwUQ xen-2.4.16/drivers/ide/piix.c
     1.6  3ddb79bfMlOcWUwjtg6oMYhGySHDDw xen-2.4.16/drivers/net/3c59x.c
     1.7 -3ddb79bfl_DWxZQFKiJ2BXrSedV4lg xen-2.4.16/drivers/net/8139cp.c
     1.8  3ddb79c0tWiE8xIFHszxipeVCGKTSA xen-2.4.16/drivers/net/Makefile
     1.9  3ddb79bfU-H1Hms4BuJEPPydjXUEaQ xen-2.4.16/drivers/net/Space.c
    1.10  3e4540ccS4bfbx9rLiLElP0F1OVwZA xen-2.4.16/drivers/net/e1000/LICENSE
    1.11 @@ -100,28 +99,14 @@ 3e4540cczrrQVyyj-s1-viyX1kMUlA xen-2.4.1
    1.12  3e4540ccvQ9Dtoh9tV-L3ULUwN9X7g xen-2.4.16/drivers/net/e1000/e1000_main.c
    1.13  3e4540cc3t7_y-YLeyMG2pX9xtdXPA xen-2.4.16/drivers/net/e1000/e1000_osdep.h
    1.14  3e4540cct_8Ig-Y1W_vM2gS_u7mC0A xen-2.4.16/drivers/net/e1000/e1000_param.c
    1.15 -3ddb79c0GejJrp1U6W4G6dYi-RiH4A xen-2.4.16/drivers/net/eepro100.c
    1.16  3e465c00t2nochqR27eEY_FBjxsUCw xen-2.4.16/drivers/net/ne/8390.c
    1.17  3e465c00AIRmk20x1vYETtnL71eGvA xen-2.4.16/drivers/net/ne/8390.h
    1.18  3e465c00UIvPTAtAcgcQWCVFa2bwww xen-2.4.16/drivers/net/ne/Makefile
    1.19  3e465c00rWSHiXmHuOWLRf7r2n8S3g xen-2.4.16/drivers/net/ne/ne.c
    1.20  3ddb79bfKvn9mt0kofpkw0QaWjxO6A xen-2.4.16/drivers/net/net_init.c
    1.21 -3ddb79c0fQgORkFlqWZdP-6cDHyFIQ xen-2.4.16/drivers/net/pcnet32.c
    1.22  3ddb79bf_CBcu3QWYwq4bNAOnM2RqQ xen-2.4.16/drivers/net/setup.c
    1.23  3e45a0c6u66EL2AI36eLOmf_abXs7g xen-2.4.16/drivers/net/tg3.c
    1.24  3e45a0c6yrXj5pmQT0PvVSJ01YLABQ xen-2.4.16/drivers/net/tg3.h
    1.25 -3ddb79bfh8ucmq_HqRSaURalpeAmPg xen-2.4.16/drivers/net/tulip/.depend
    1.26 -3ddb79bfsJ-hdQ17EXTFiUOHisjNgQ xen-2.4.16/drivers/net/tulip/21142.c
    1.27 -3ddb79bf0lzTL-ywAdOO7vctTYAmJA xen-2.4.16/drivers/net/tulip/ChangeLog
    1.28 -3ddb79bfRbGBTu5mznHtxpFPtnQYSQ xen-2.4.16/drivers/net/tulip/Makefile
    1.29 -3ddb79bfLLamkCaJZDJ7i6qrCUhwBw xen-2.4.16/drivers/net/tulip/eeprom.c
    1.30 -3ddb79bf-zt39-zIUgWC9Kb4As--Ew xen-2.4.16/drivers/net/tulip/interrupt.c
    1.31 -3ddb79bfdr1I4DtFnXCzpaHkEkHE2Q xen-2.4.16/drivers/net/tulip/media.c
    1.32 -3ddb79bftPnJDLCAo0Do4KPr5raERA xen-2.4.16/drivers/net/tulip/pnic.c
    1.33 -3ddb79bf5lr4NIjy1oZOM_jhpxGidw xen-2.4.16/drivers/net/tulip/pnic2.c
    1.34 -3ddb79bfBhawkz-2DT9lakMPbqzljQ xen-2.4.16/drivers/net/tulip/timer.c
    1.35 -3ddb79bf7yw7hGBMM60aMgMgxY_G2g xen-2.4.16/drivers/net/tulip/tulip.h
    1.36 -3ddb79bfhUr3baP8Lf4oZjhBX7i5kw xen-2.4.16/drivers/net/tulip/tulip_core.c
    1.37  3ddb79beUWngyIhMHgyPtuTem4o4JA xen-2.4.16/drivers/pci/Makefile
    1.38  3ddb79beU9td0Mnm0VUMklerBa37qQ xen-2.4.16/drivers/pci/compat.c
    1.39  3ddb79beHkGQE58z5t5gyUCYiwOxvw xen-2.4.16/drivers/pci/gen-devlist.c
     2.1 --- a/xen-2.4.16/drivers/net/8139cp.c	Fri Feb 14 17:11:31 2003 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,1338 +0,0 @@
     2.4 -/* 8139cp.c: A Linux PCI Ethernet driver for the RealTek 8139C+ chips. */
     2.5 -/*
     2.6 -	Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com>
     2.7 -
     2.8 -	Copyright (C) 2000, 2001 David S. Miller (davem@redhat.com) [sungem.c]
     2.9 -	Copyright 2001 Manfred Spraul				    [natsemi.c]
    2.10 -	Copyright 1999-2001 by Donald Becker.			    [natsemi.c]
    2.11 -       	Written 1997-2001 by Donald Becker.			    [8139too.c]
    2.12 -	Copyright 1998-2001 by Jes Sorensen, <jes@trained-monkey.org>. [acenic.c]
    2.13 -
    2.14 -	This software may be used and distributed according to the terms of
    2.15 -	the GNU General Public License (GPL), incorporated herein by reference.
    2.16 -	Drivers based on or derived from this code fall under the GPL and must
    2.17 -	retain the authorship, copyright and license notice.  This file is not
    2.18 -	a complete program and may only be used when the entire operating
    2.19 -	system is licensed under the GPL.
    2.20 -
    2.21 -	See the file COPYING in this distribution for more information.
    2.22 -
    2.23 -	TODO, in rough priority order:
    2.24 -	* dev->tx_timeout
    2.25 -	* LinkChg interrupt
    2.26 -	* ETHTOOL_[GS]SET
    2.27 -	* Support forcing media type with a module parameter,
    2.28 -	  like dl2k.c/sundance.c
    2.29 -	* Implement PCI suspend/resume
    2.30 -	* Constants (module parms?) for Rx work limit
    2.31 -	* support 64-bit PCI DMA
    2.32 -	* Complete reset on PciErr
    2.33 -	* Consider Rx interrupt mitigation using TimerIntr
    2.34 -	* Implement 8139C+ statistics dump; maybe not...
    2.35 -	  h/w stats can be reset only by software reset
    2.36 -	* Rx checksumming
    2.37 -	* Tx checksumming
    2.38 -	* ETHTOOL_GREGS, ETHTOOL_[GS]WOL,
    2.39 -	  ETHTOOL_[GS]MSGLVL, ETHTOOL_NWAY_RST
    2.40 -	* Jumbo frames / dev->change_mtu
    2.41 -	* Investigate using skb->priority with h/w VLAN priority
    2.42 -	* Investigate using High Priority Tx Queue with skb->priority
    2.43 -	* Adjust Rx FIFO threshold and Max Rx DMA burst on Rx FIFO error
    2.44 -	* Adjust Tx FIFO threshold and Max Tx DMA burst on Tx FIFO error
    2.45 -
    2.46 - */
    2.47 -
    2.48 -#define DRV_NAME		"8139cp"
    2.49 -#define DRV_VERSION		"0.0.5"
    2.50 -#define DRV_RELDATE		"Oct 19, 2001"
    2.51 -
    2.52 -
    2.53 -#include <linux/config.h>
    2.54 -#include <linux/module.h>
    2.55 -//#include <linux/kernel.h>
    2.56 -#include <linux/netdevice.h>
    2.57 -#include <linux/etherdevice.h>
    2.58 -#include <linux/init.h>
    2.59 -#include <linux/pci.h>
    2.60 -#include <linux/delay.h>
    2.61 -#include <linux/ethtool.h>
    2.62 -#include <asm/io.h>
    2.63 -#include <asm/uaccess.h>
    2.64 -
    2.65 -/* These identify the driver base version and may not be removed. */
    2.66 -static char version[] __devinitdata =
    2.67 -KERN_INFO DRV_NAME " 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n";
    2.68 -
    2.69 -MODULE_AUTHOR("Jeff Garzik <jgarzik@mandrakesoft.com>");
    2.70 -MODULE_DESCRIPTION("RealTek RTL-8139C+ series 10/100 PCI Ethernet driver");
    2.71 -MODULE_LICENSE("GPL");
    2.72 -
    2.73 -static int debug = -1;
    2.74 -MODULE_PARM (debug, "i");
    2.75 -MODULE_PARM_DESC (debug, "8139cp bitmapped message enable number");
    2.76 -
    2.77 -/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
    2.78 -   The RTL chips use a 64 element hash table based on the Ethernet CRC.  */
    2.79 -static int multicast_filter_limit = 32;
    2.80 -MODULE_PARM (multicast_filter_limit, "i");
    2.81 -MODULE_PARM_DESC (multicast_filter_limit, "8139cp maximum number of filtered multicast addresses");
    2.82 -
    2.83 -/* Set the copy breakpoint for the copy-only-tiny-buffer Rx structure. */
    2.84 -/*#if defined(__alpha__) || defined(__arm__) || defined(__hppa__) \
    2.85 -        || defined(__sparc_) || defined(__ia64__) \
    2.86 -        || defined(__sh__) || defined(__mips__)
    2.87 -static int rx_copybreak = 1518;
    2.88 -#else
    2.89 -static int rx_copybreak = 100;
    2.90 -#endif*/
    2.91 -
    2.92 -/* Xen doesn't do rx_copybreak in drivers. */
    2.93 -static int rx_copybreak = 0;
    2.94 -        
    2.95 -MODULE_PARM (rx_copybreak, "i");
    2.96 -MODULE_PARM_DESC (rx_copybreak, "8139cp Breakpoint at which Rx packets are copied");
    2.97 -
    2.98 -#define PFX			DRV_NAME ": "
    2.99 -
   2.100 -#define CP_DEF_MSG_ENABLE	(NETIF_MSG_DRV		| \
   2.101 -				 NETIF_MSG_PROBE 	| \
   2.102 -				 NETIF_MSG_LINK)
   2.103 -#define CP_REGS_SIZE		(0xff + 1)
   2.104 -#define CP_RX_RING_SIZE		64
   2.105 -#define CP_TX_RING_SIZE		64
   2.106 -#define CP_RING_BYTES		\
   2.107 -		((sizeof(struct cp_desc) * CP_RX_RING_SIZE) +	\
   2.108 -		(sizeof(struct cp_desc) * CP_TX_RING_SIZE))
   2.109 -#define NEXT_TX(N)		(((N) + 1) & (CP_TX_RING_SIZE - 1))
   2.110 -#define NEXT_RX(N)		(((N) + 1) & (CP_RX_RING_SIZE - 1))
   2.111 -#define TX_BUFFS_AVAIL(CP)					\
   2.112 -	(((CP)->tx_tail <= (CP)->tx_head) ?			\
   2.113 -	  (CP)->tx_tail + (CP_TX_RING_SIZE - 1) - (CP)->tx_head :	\
   2.114 -	  (CP)->tx_tail - (CP)->tx_head - 1)
   2.115 -#define CP_CHIP_VERSION		0x76
   2.116 -
   2.117 -#define PKT_BUF_SZ		1536	/* Size of each temporary Rx buffer.*/
   2.118 -#define RX_OFFSET		2
   2.119 -
   2.120 -/* The following settings are log_2(bytes)-4:  0 == 16 bytes .. 6==1024, 7==end of packet. */
   2.121 -#define RX_FIFO_THRESH		5	/* Rx buffer level before first PCI xfer.  */
   2.122 -#define RX_DMA_BURST		4	/* Maximum PCI burst, '4' is 256 */
   2.123 -#define TX_DMA_BURST		6	/* Maximum PCI burst, '6' is 1024 */
   2.124 -#define TX_EARLY_THRESH		256	/* Early Tx threshold, in bytes */
   2.125 -
   2.126 -/* Time in jiffies before concluding the transmitter is hung. */
   2.127 -#define TX_TIMEOUT  (6*HZ)
   2.128 -
   2.129 -
   2.130 -enum {
   2.131 -	/* NIC register offsets */
   2.132 -	MAC0		= 0x00,	/* Ethernet hardware address. */
   2.133 -	MAR0		= 0x08,	/* Multicast filter. */
   2.134 -	TxRingAddr	= 0x20, /* 64-bit start addr of Tx ring */
   2.135 -	HiTxRingAddr	= 0x28, /* 64-bit start addr of high priority Tx ring */
   2.136 -	Cmd		= 0x37, /* Command register */
   2.137 -	IntrMask	= 0x3C, /* Interrupt mask */
   2.138 -	IntrStatus	= 0x3E, /* Interrupt status */
   2.139 -	TxConfig	= 0x40, /* Tx configuration */
   2.140 -	ChipVersion	= 0x43, /* 8-bit chip version, inside TxConfig */
   2.141 -	RxConfig	= 0x44, /* Rx configuration */
   2.142 -	Cfg9346		= 0x50, /* EEPROM select/control; Cfg reg [un]lock */
   2.143 -	Config1		= 0x52, /* Config1 */
   2.144 -	Config3		= 0x59, /* Config3 */
   2.145 -	Config4		= 0x5A, /* Config4 */
   2.146 -	MultiIntr	= 0x5C, /* Multiple interrupt select */
   2.147 -	Config5		= 0xD8,	/* Config5 */
   2.148 -	TxPoll		= 0xD9,	/* Tell chip to check Tx descriptors for work */
   2.149 -	CpCmd		= 0xE0, /* C+ Command register (C+ mode only) */
   2.150 -	RxRingAddr	= 0xE4, /* 64-bit start addr of Rx ring */
   2.151 -	TxThresh	= 0xEC, /* Early Tx threshold */
   2.152 -	OldRxBufAddr	= 0x30, /* DMA address of Rx ring buffer (C mode) */
   2.153 -	OldTSD0		= 0x10, /* DMA address of first Tx desc (C mode) */
   2.154 -
   2.155 -	/* Tx and Rx status descriptors */
   2.156 -	DescOwn		= (1 << 31), /* Descriptor is owned by NIC */
   2.157 -	RingEnd		= (1 << 30), /* End of descriptor ring */
   2.158 -	FirstFrag	= (1 << 29), /* First segment of a packet */
   2.159 -	LastFrag	= (1 << 28), /* Final segment of a packet */
   2.160 -	TxError		= (1 << 23), /* Tx error summary */
   2.161 -	RxError		= (1 << 20), /* Rx error summary */
   2.162 -	IPCS		= (1 << 18), /* Calculate IP checksum */
   2.163 -	UDPCS		= (1 << 17), /* Calculate UDP/IP checksum */
   2.164 -	TCPCS		= (1 << 16), /* Calculate TCP/IP checksum */
   2.165 -	IPFail		= (1 << 15), /* IP checksum failed */
   2.166 -	UDPFail		= (1 << 14), /* UDP/IP checksum failed */
   2.167 -	TCPFail		= (1 << 13), /* TCP/IP checksum failed */
   2.168 -	NormalTxPoll	= (1 << 6),  /* One or more normal Tx packets to send */
   2.169 -	PID1		= (1 << 17), /* 2 protocol id bits:  0==non-IP, */
   2.170 -	PID0		= (1 << 16), /* 1==UDP/IP, 2==TCP/IP, 3==IP */
   2.171 -	TxFIFOUnder	= (1 << 25), /* Tx FIFO underrun */
   2.172 -	TxOWC		= (1 << 22), /* Tx Out-of-window collision */
   2.173 -	TxLinkFail	= (1 << 21), /* Link failed during Tx of packet */
   2.174 -	TxMaxCol	= (1 << 20), /* Tx aborted due to excessive collisions */
   2.175 -	TxColCntShift	= 16,	     /* Shift, to get 4-bit Tx collision cnt */
   2.176 -	TxColCntMask	= 0x01 | 0x02 | 0x04 | 0x08, /* 4-bit collision count */
   2.177 -	RxErrFrame	= (1 << 27), /* Rx frame alignment error */
   2.178 -	RxMcast		= (1 << 26), /* Rx multicast packet rcv'd */
   2.179 -	RxErrCRC	= (1 << 18), /* Rx CRC error */
   2.180 -	RxErrRunt	= (1 << 19), /* Rx error, packet < 64 bytes */
   2.181 -	RxErrLong	= (1 << 21), /* Rx error, packet > 4096 bytes */
   2.182 -	RxErrFIFO	= (1 << 22), /* Rx error, FIFO overflowed, pkt bad */
   2.183 -
   2.184 -	/* RxConfig register */
   2.185 -	RxCfgFIFOShift	= 13,	     /* Shift, to get Rx FIFO thresh value */
   2.186 -	RxCfgDMAShift	= 8,	     /* Shift, to get Rx Max DMA value */
   2.187 -	AcceptErr	= 0x20,	     /* Accept packets with CRC errors */
   2.188 -	AcceptRunt	= 0x10,	     /* Accept runt (<64 bytes) packets */
   2.189 -	AcceptBroadcast	= 0x08,	     /* Accept broadcast packets */
   2.190 -	AcceptMulticast	= 0x04,	     /* Accept multicast packets */
   2.191 -	AcceptMyPhys	= 0x02,	     /* Accept pkts with our MAC as dest */
   2.192 -	AcceptAllPhys	= 0x01,	     /* Accept all pkts w/ physical dest */
   2.193 -
   2.194 -	/* IntrMask / IntrStatus registers */
   2.195 -	PciErr		= (1 << 15), /* System error on the PCI bus */
   2.196 -	TimerIntr	= (1 << 14), /* Asserted when TCTR reaches TimerInt value */
   2.197 -	LenChg		= (1 << 13), /* Cable length change */
   2.198 -	SWInt		= (1 << 8),  /* Software-requested interrupt */
   2.199 -	TxEmpty		= (1 << 7),  /* No Tx descriptors available */
   2.200 -	RxFIFOOvr	= (1 << 6),  /* Rx FIFO Overflow */
   2.201 -	LinkChg		= (1 << 5),  /* Packet underrun, or link change */
   2.202 -	RxEmpty		= (1 << 4),  /* No Rx descriptors available */
   2.203 -	TxErr		= (1 << 3),  /* Tx error */
   2.204 -	TxOK		= (1 << 2),  /* Tx packet sent */
   2.205 -	RxErr		= (1 << 1),  /* Rx error */
   2.206 -	RxOK		= (1 << 0),  /* Rx packet received */
   2.207 -	IntrResvd	= (1 << 10), /* reserved, according to RealTek engineers,
   2.208 -					but hardware likes to raise it */
   2.209 -
   2.210 -	IntrAll		= PciErr | TimerIntr | LenChg | SWInt | TxEmpty |
   2.211 -			  RxFIFOOvr | LinkChg | RxEmpty | TxErr | TxOK |
   2.212 -			  RxErr | RxOK | IntrResvd,
   2.213 -
   2.214 -	/* C mode command register */
   2.215 -	CmdReset	= (1 << 4),  /* Enable to reset; self-clearing */
   2.216 -	RxOn		= (1 << 3),  /* Rx mode enable */
   2.217 -	TxOn		= (1 << 2),  /* Tx mode enable */
   2.218 -
   2.219 -	/* C+ mode command register */
   2.220 -	RxChkSum	= (1 << 5),  /* Rx checksum offload enable */
   2.221 -	PCIMulRW	= (1 << 3),  /* Enable PCI read/write multiple */
   2.222 -	CpRxOn		= (1 << 1),  /* Rx mode enable */
   2.223 -	CpTxOn		= (1 << 0),  /* Tx mode enable */
   2.224 -
   2.225 -	/* Cfg9436 EEPROM control register */
   2.226 -	Cfg9346_Lock	= 0x00,	     /* Lock ConfigX/MII register access */
   2.227 -	Cfg9346_Unlock	= 0xC0,	     /* Unlock ConfigX/MII register access */
   2.228 -
   2.229 -	/* TxConfig register */
   2.230 -	IFG		= (1 << 25) | (1 << 24), /* standard IEEE interframe gap */
   2.231 -	TxDMAShift	= 8,	     /* DMA burst value (0-7) is shift this many bits */
   2.232 -
   2.233 -	/* Early Tx Threshold register */
   2.234 -	TxThreshMask	= 0x3f,	     /* Mask bits 5-0 */
   2.235 -	TxThreshMax	= 2048,	     /* Max early Tx threshold */
   2.236 -
   2.237 -	/* Config1 register */
   2.238 -	DriverLoaded	= (1 << 5),  /* Software marker, driver is loaded */
   2.239 -	PMEnable	= (1 << 0),  /* Enable various PM features of chip */
   2.240 -
   2.241 -	/* Config3 register */
   2.242 -	PARMEnable	= (1 << 6),  /* Enable auto-loading of PHY parms */
   2.243 -
   2.244 -	/* Config5 register */
   2.245 -	PMEStatus	= (1 << 0),  /* PME status can be reset by PCI RST# */
   2.246 -};
   2.247 -
   2.248 -static const unsigned int cp_intr_mask =
   2.249 -	PciErr | LinkChg |
   2.250 -	RxOK | RxErr | RxEmpty | RxFIFOOvr |
   2.251 -	TxOK | TxErr | TxEmpty;
   2.252 -
   2.253 -static const unsigned int cp_rx_config =
   2.254 -	  (RX_FIFO_THRESH << RxCfgFIFOShift) |
   2.255 -	  (RX_DMA_BURST << RxCfgDMAShift);
   2.256 -
   2.257 -struct cp_desc {
   2.258 -	u32		opts1;
   2.259 -	u32		opts2;
   2.260 -	u32		addr_lo;
   2.261 -	u32		addr_hi;
   2.262 -};
   2.263 -
   2.264 -struct ring_info {
   2.265 -	struct sk_buff		*skb;
   2.266 -	dma_addr_t		mapping;
   2.267 -	unsigned		frag;
   2.268 -};
   2.269 -
   2.270 -struct cp_extra_stats {
   2.271 -	unsigned long		rx_frags;
   2.272 -};
   2.273 -
   2.274 -struct cp_private {
   2.275 -	unsigned		tx_head;
   2.276 -	unsigned		tx_tail;
   2.277 -	unsigned		rx_tail;
   2.278 -
   2.279 -	void			*regs;
   2.280 -	struct net_device	*dev;
   2.281 -	spinlock_t		lock;
   2.282 -
   2.283 -	struct cp_desc		*rx_ring;
   2.284 -	struct cp_desc		*tx_ring;
   2.285 -	struct ring_info	tx_skb[CP_TX_RING_SIZE];
   2.286 -	struct ring_info	rx_skb[CP_RX_RING_SIZE];
   2.287 -	unsigned		rx_buf_sz;
   2.288 -	dma_addr_t		ring_dma;
   2.289 -
   2.290 -	u32			msg_enable;
   2.291 -
   2.292 -	struct net_device_stats net_stats;
   2.293 -	struct cp_extra_stats	cp_stats;
   2.294 -
   2.295 -	struct pci_dev		*pdev;
   2.296 -	u32			rx_config;
   2.297 -
   2.298 -	struct sk_buff		*frag_skb;
   2.299 -	unsigned		dropping_frag : 1;
   2.300 -};
   2.301 -
   2.302 -#define cpr8(reg)	readb(cp->regs + (reg))
   2.303 -#define cpr16(reg)	readw(cp->regs + (reg))
   2.304 -#define cpr32(reg)	readl(cp->regs + (reg))
   2.305 -#define cpw8(reg,val)	writeb((val), cp->regs + (reg))
   2.306 -#define cpw16(reg,val)	writew((val), cp->regs + (reg))
   2.307 -#define cpw32(reg,val)	writel((val), cp->regs + (reg))
   2.308 -#define cpw8_f(reg,val) do {			\
   2.309 -	writeb((val), cp->regs + (reg));	\
   2.310 -	readb(cp->regs + (reg));		\
   2.311 -	} while (0)
   2.312 -#define cpw16_f(reg,val) do {			\
   2.313 -	writew((val), cp->regs + (reg));	\
   2.314 -	readw(cp->regs + (reg));		\
   2.315 -	} while (0)
   2.316 -#define cpw32_f(reg,val) do {			\
   2.317 -	writel((val), cp->regs + (reg));	\
   2.318 -	readl(cp->regs + (reg));		\
   2.319 -	} while (0)
   2.320 -
   2.321 -
   2.322 -static void __cp_set_rx_mode (struct net_device *dev);
   2.323 -static void cp_tx (struct cp_private *cp);
   2.324 -static void cp_clean_rings (struct cp_private *cp);
   2.325 -
   2.326 -
   2.327 -static struct pci_device_id cp_pci_tbl[] __devinitdata = {
   2.328 -	{ PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
   2.329 -	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
   2.330 -	{ },
   2.331 -};
   2.332 -MODULE_DEVICE_TABLE(pci, cp_pci_tbl);
   2.333 -
   2.334 -static inline void cp_rx_skb (struct cp_private *cp, struct sk_buff *skb)
   2.335 -{
   2.336 -	skb->protocol = eth_type_trans (skb, cp->dev);
   2.337 -
   2.338 -	cp->net_stats.rx_packets++;
   2.339 -	cp->net_stats.rx_bytes += skb->len;
   2.340 -	cp->dev->last_rx = jiffies;
   2.341 -	netif_rx (skb);
   2.342 -}
   2.343 -
   2.344 -static inline void cp_rx_err_acct (struct cp_private *cp, unsigned rx_tail,
   2.345 -				   u32 status, u32 len)
   2.346 -{
   2.347 -	if (netif_msg_rx_err (cp))
   2.348 -		printk (KERN_DEBUG
   2.349 -			"%s: rx err, slot %d status 0x%x len %d\n",
   2.350 -			cp->dev->name, rx_tail, status, len);
   2.351 -	cp->net_stats.rx_errors++;
   2.352 -	if (status & RxErrFrame)
   2.353 -		cp->net_stats.rx_frame_errors++;
   2.354 -	if (status & RxErrCRC)
   2.355 -		cp->net_stats.rx_crc_errors++;
   2.356 -	if (status & RxErrRunt)
   2.357 -		cp->net_stats.rx_length_errors++;
   2.358 -	if (status & RxErrLong)
   2.359 -		cp->net_stats.rx_length_errors++;
   2.360 -	if (status & RxErrFIFO)
   2.361 -		cp->net_stats.rx_fifo_errors++;
   2.362 -}
   2.363 -
   2.364 -static void cp_rx_frag (struct cp_private *cp, unsigned rx_tail,
   2.365 -			struct sk_buff *skb, u32 status, u32 len)
   2.366 -{
   2.367 -	struct sk_buff *copy_skb, *frag_skb = cp->frag_skb;
   2.368 -	unsigned orig_len = frag_skb ? frag_skb->len : 0;
   2.369 -	unsigned target_len = orig_len + len;
   2.370 -	unsigned first_frag = status & FirstFrag;
   2.371 -	unsigned last_frag = status & LastFrag;
   2.372 -
   2.373 -	if (netif_msg_rx_status (cp))
   2.374 -		printk (KERN_DEBUG "%s: rx %s%sfrag, slot %d status 0x%x len %d\n",
   2.375 -			cp->dev->name,
   2.376 -			cp->dropping_frag ? "dropping " : "",
   2.377 -			first_frag ? "first " :
   2.378 -			last_frag ? "last " : "",
   2.379 -			rx_tail, status, len);
   2.380 -
   2.381 -	cp->cp_stats.rx_frags++;
   2.382 -
   2.383 -	if (!frag_skb && !first_frag)
   2.384 -		cp->dropping_frag = 1;
   2.385 -	if (cp->dropping_frag)
   2.386 -		goto drop_frag;
   2.387 -
   2.388 -	copy_skb = dev_alloc_skb (target_len + RX_OFFSET);
   2.389 -	if (!copy_skb) {
   2.390 -		printk(KERN_WARNING "%s: rx slot %d alloc failed\n",
   2.391 -		       cp->dev->name, rx_tail);
   2.392 -
   2.393 -		cp->dropping_frag = 1;
   2.394 -drop_frag:
   2.395 -		if (frag_skb) {
   2.396 -			dev_kfree_skb_irq(frag_skb);
   2.397 -			cp->frag_skb = NULL;
   2.398 -		}
   2.399 -		if (last_frag) {
   2.400 -			cp->net_stats.rx_dropped++;
   2.401 -			cp->dropping_frag = 0;
   2.402 -		}
   2.403 -		return;
   2.404 -	}
   2.405 -
   2.406 -	copy_skb->dev = cp->dev;
   2.407 -	skb_reserve(copy_skb, RX_OFFSET);
   2.408 -	skb_put(copy_skb, target_len);
   2.409 -	if (frag_skb) {
   2.410 -		memcpy(copy_skb->data, frag_skb->data, orig_len);
   2.411 -		dev_kfree_skb_irq(frag_skb);
   2.412 -	}
   2.413 -	pci_dma_sync_single(cp->pdev, cp->rx_skb[rx_tail].mapping,
   2.414 -			    len, PCI_DMA_FROMDEVICE);
   2.415 -	memcpy(copy_skb->data + orig_len, skb->data, len);
   2.416 -
   2.417 -	copy_skb->ip_summed = CHECKSUM_NONE;
   2.418 -
   2.419 -	if (last_frag) {
   2.420 -		if (status & (RxError | RxErrFIFO)) {
   2.421 -			cp_rx_err_acct(cp, rx_tail, status, len);
   2.422 -			dev_kfree_skb_irq(copy_skb);
   2.423 -		} else
   2.424 -			cp_rx_skb(cp, copy_skb);
   2.425 -		cp->frag_skb = NULL;
   2.426 -	} else {
   2.427 -		cp->frag_skb = copy_skb;
   2.428 -	}
   2.429 -}
   2.430 -
   2.431 -static void cp_rx (struct cp_private *cp)
   2.432 -{
   2.433 -	unsigned rx_tail = cp->rx_tail;
   2.434 -	unsigned rx_work = 100;
   2.435 -
   2.436 -	while (rx_work--) {
   2.437 -		u32 status, len;
   2.438 -		dma_addr_t mapping;
   2.439 -		struct sk_buff *skb, *copy_skb;
   2.440 -		unsigned copying_skb, buflen;
   2.441 -
   2.442 -		skb = cp->rx_skb[rx_tail].skb;
   2.443 -		if (!skb)
   2.444 -			BUG();
   2.445 -		rmb();
   2.446 -		status = le32_to_cpu(cp->rx_ring[rx_tail].opts1);
   2.447 -		if (status & DescOwn)
   2.448 -			break;
   2.449 -
   2.450 -		len = (status & 0x1fff) - 4;
   2.451 -		mapping = cp->rx_skb[rx_tail].mapping;
   2.452 -
   2.453 -		if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag)) {
   2.454 -			cp_rx_frag(cp, rx_tail, skb, status, len);
   2.455 -			goto rx_next;
   2.456 -		}
   2.457 -
   2.458 -		if (status & (RxError | RxErrFIFO)) {
   2.459 -			cp_rx_err_acct(cp, rx_tail, status, len);
   2.460 -			goto rx_next;
   2.461 -		}
   2.462 -
   2.463 -		copying_skb = (len <= rx_copybreak);
   2.464 -
   2.465 -		if (netif_msg_rx_status(cp))
   2.466 -			printk(KERN_DEBUG "%s: rx slot %d status 0x%x len %d copying? %d\n",
   2.467 -			       cp->dev->name, rx_tail, status, len,
   2.468 -			       copying_skb);
   2.469 -
   2.470 -		buflen = copying_skb ? len : cp->rx_buf_sz;
   2.471 -		copy_skb = dev_alloc_skb (buflen + RX_OFFSET);
   2.472 -		if (!copy_skb) {
   2.473 -			cp->net_stats.rx_dropped++;
   2.474 -			goto rx_next;
   2.475 -		}
   2.476 -
   2.477 -		skb_reserve(copy_skb, RX_OFFSET);
   2.478 -		copy_skb->dev = cp->dev;
   2.479 -
   2.480 -		if (!copying_skb) {
   2.481 -			pci_unmap_single(cp->pdev, mapping,
   2.482 -					 buflen, PCI_DMA_FROMDEVICE);
   2.483 -			skb->ip_summed = CHECKSUM_NONE;
   2.484 -			skb_trim(skb, len);
   2.485 -
   2.486 -			mapping =
   2.487 -			cp->rx_skb[rx_tail].mapping =
   2.488 -				pci_map_single(cp->pdev, copy_skb->data,
   2.489 -					       buflen, PCI_DMA_FROMDEVICE);
   2.490 -			cp->rx_skb[rx_tail].skb = copy_skb;
   2.491 -			skb_put(copy_skb, buflen);
   2.492 -		} else {
   2.493 -			skb_put(copy_skb, len);
   2.494 -			pci_dma_sync_single(cp->pdev, mapping, len, PCI_DMA_FROMDEVICE);
   2.495 -			memcpy(copy_skb->data, skb->data, len);
   2.496 -
   2.497 -			/* We'll reuse the original ring buffer. */
   2.498 -			skb = copy_skb;
   2.499 -		}
   2.500 -
   2.501 -		cp_rx_skb(cp, skb);
   2.502 -
   2.503 -rx_next:
   2.504 -		if (rx_tail == (CP_RX_RING_SIZE - 1))
   2.505 -			cp->rx_ring[rx_tail].opts1 =
   2.506 -				cpu_to_le32(DescOwn | RingEnd | cp->rx_buf_sz);
   2.507 -		else
   2.508 -			cp->rx_ring[rx_tail].opts1 =
   2.509 -				cpu_to_le32(DescOwn | cp->rx_buf_sz);
   2.510 -		cp->rx_ring[rx_tail].opts2 = 0;
   2.511 -		cp->rx_ring[rx_tail].addr_lo = cpu_to_le32(mapping);
   2.512 -		rx_tail = NEXT_RX(rx_tail);
   2.513 -	}
   2.514 -
   2.515 -	if (!rx_work)
   2.516 -		printk(KERN_WARNING "%s: rx work limit reached\n", cp->dev->name);
   2.517 -
   2.518 -	cp->rx_tail = rx_tail;
   2.519 -}
   2.520 -
   2.521 -static void cp_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
   2.522 -{
   2.523 -	struct net_device *dev = dev_instance;
   2.524 -	struct cp_private *cp = dev->priv;
   2.525 -	u16 status;
   2.526 -
   2.527 -	status = cpr16(IntrStatus);
   2.528 -	if (!status || (status == 0xFFFF))
   2.529 -		return;
   2.530 -
   2.531 -	if (netif_msg_intr(cp))
   2.532 -		printk(KERN_DEBUG "%s: intr, status %04x cmd %02x cpcmd %04x\n",
   2.533 -		        dev->name, status, cpr8(Cmd), cpr16(CpCmd));
   2.534 -
   2.535 -	spin_lock(&cp->lock);
   2.536 -
   2.537 -	if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr))
   2.538 -		cp_rx(cp);
   2.539 -	if (status & (TxOK | TxErr | TxEmpty | SWInt))
   2.540 -		cp_tx(cp);
   2.541 -
   2.542 -	cpw16_f(IntrStatus, status);
   2.543 -
   2.544 -	if (status & PciErr) {
   2.545 -		u16 pci_status;
   2.546 -
   2.547 -		pci_read_config_word(cp->pdev, PCI_STATUS, &pci_status);
   2.548 -		pci_write_config_word(cp->pdev, PCI_STATUS, pci_status);
   2.549 -		printk(KERN_ERR "%s: PCI bus error, status=%04x, PCI status=%04x\n",
   2.550 -		       dev->name, status, pci_status);
   2.551 -	}
   2.552 -
   2.553 -	spin_unlock(&cp->lock);
   2.554 -}
   2.555 -
   2.556 -static void cp_tx (struct cp_private *cp)
   2.557 -{
   2.558 -	unsigned tx_head = cp->tx_head;
   2.559 -	unsigned tx_tail = cp->tx_tail;
   2.560 -
   2.561 -	while (tx_tail != tx_head) {
   2.562 -		struct sk_buff *skb;
   2.563 -		u32 status;
   2.564 -
   2.565 -		rmb();
   2.566 -		status = le32_to_cpu(cp->tx_ring[tx_tail].opts1);
   2.567 -		if (status & DescOwn)
   2.568 -			break;
   2.569 -
   2.570 -		skb = cp->tx_skb[tx_tail].skb;
   2.571 -		if (!skb)
   2.572 -			BUG();
   2.573 -
   2.574 -		pci_unmap_single(cp->pdev, cp->tx_skb[tx_tail].mapping,
   2.575 -					skb->len, PCI_DMA_TODEVICE);
   2.576 -
   2.577 -		if (status & LastFrag) {
   2.578 -			if (status & (TxError | TxFIFOUnder)) {
   2.579 -				if (netif_msg_tx_err(cp))
   2.580 -					printk(KERN_DEBUG "%s: tx err, status 0x%x\n",
   2.581 -					       cp->dev->name, status);
   2.582 -				cp->net_stats.tx_errors++;
   2.583 -				if (status & TxOWC)
   2.584 -					cp->net_stats.tx_window_errors++;
   2.585 -				if (status & TxMaxCol)
   2.586 -					cp->net_stats.tx_aborted_errors++;
   2.587 -				if (status & TxLinkFail)
   2.588 -					cp->net_stats.tx_carrier_errors++;
   2.589 -				if (status & TxFIFOUnder)
   2.590 -					cp->net_stats.tx_fifo_errors++;
   2.591 -			} else {
   2.592 -				cp->net_stats.collisions +=
   2.593 -					((status >> TxColCntShift) & TxColCntMask);
   2.594 -				cp->net_stats.tx_packets++;
   2.595 -				cp->net_stats.tx_bytes += skb->len;
   2.596 -				if (netif_msg_tx_done(cp))
   2.597 -					printk(KERN_DEBUG "%s: tx done, slot %d\n", cp->dev->name, tx_tail);
   2.598 -			}
   2.599 -			dev_kfree_skb_irq(skb);
   2.600 -		}
   2.601 -
   2.602 -		cp->tx_skb[tx_tail].skb = NULL;
   2.603 -
   2.604 -		tx_tail = NEXT_TX(tx_tail);
   2.605 -	}
   2.606 -
   2.607 -	cp->tx_tail = tx_tail;
   2.608 -
   2.609 -	if (netif_queue_stopped(cp->dev) && (TX_BUFFS_AVAIL(cp) > 1))
   2.610 -		netif_wake_queue(cp->dev);
   2.611 -}
   2.612 -
   2.613 -static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
   2.614 -{
   2.615 -	struct cp_private *cp = dev->priv;
   2.616 -	unsigned entry;
   2.617 -	u32 eor;
   2.618 -
   2.619 -	spin_lock_irq(&cp->lock);
   2.620 -
   2.621 -	if (TX_BUFFS_AVAIL(cp) <= (skb_shinfo(skb)->nr_frags + 1)) {
   2.622 -		netif_stop_queue(dev);
   2.623 -		spin_unlock_irq(&cp->lock);
   2.624 -		return 1;
   2.625 -	}
   2.626 -
   2.627 -	entry = cp->tx_head;
   2.628 -	eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
   2.629 -	if (skb_shinfo(skb)->nr_frags == 0) {
   2.630 -		struct cp_desc *txd = &cp->tx_ring[entry];
   2.631 -		u32 mapping, len;
   2.632 -
   2.633 -		len = skb->len;
   2.634 -		mapping = pci_map_single(cp->pdev, skb->data, len, PCI_DMA_TODEVICE);
   2.635 -		eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
   2.636 -		txd->opts2 = 0;
   2.637 -		txd->addr_lo = cpu_to_le32(mapping);
   2.638 -		wmb();
   2.639 -
   2.640 -#ifdef CP_TX_CHECKSUM
   2.641 -		txd->opts1 = cpu_to_le32(eor | len | DescOwn | FirstFrag |
   2.642 -			LastFrag | IPCS | UDPCS | TCPCS);
   2.643 -#else
   2.644 -		txd->opts1 = cpu_to_le32(eor | len | DescOwn | FirstFrag |
   2.645 -			LastFrag);
   2.646 -#endif
   2.647 -		wmb();
   2.648 -
   2.649 -		cp->tx_skb[entry].skb = skb;
   2.650 -		cp->tx_skb[entry].mapping = mapping;
   2.651 -		cp->tx_skb[entry].frag = 0;
   2.652 -		entry = NEXT_TX(entry);
   2.653 -	} else {
   2.654 -		struct cp_desc *txd;
   2.655 -		u32 first_len, first_mapping;
   2.656 -		int frag, first_entry = entry;
   2.657 -
   2.658 -		/* We must give this initial chunk to the device last.
   2.659 -		 * Otherwise we could race with the device.
   2.660 -		 */
   2.661 -		first_len = skb->len - skb->data_len;
   2.662 -		first_mapping = pci_map_single(cp->pdev, skb->data,
   2.663 -					       first_len, PCI_DMA_TODEVICE);
   2.664 -		cp->tx_skb[entry].skb = skb;
   2.665 -		cp->tx_skb[entry].mapping = first_mapping;
   2.666 -		cp->tx_skb[entry].frag = 1;
   2.667 -		entry = NEXT_TX(entry);
   2.668 -
   2.669 -		for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) {
   2.670 -			skb_frag_t *this_frag = &skb_shinfo(skb)->frags[frag];
   2.671 -			u32 len, mapping;
   2.672 -			u32 ctrl;
   2.673 -
   2.674 -			len = this_frag->size;
   2.675 -			mapping = pci_map_single(cp->pdev,
   2.676 -						 ((void *) page_address(this_frag->page) +
   2.677 -						  this_frag->page_offset),
   2.678 -						 len, PCI_DMA_TODEVICE);
   2.679 -			eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
   2.680 -#ifdef CP_TX_CHECKSUM
   2.681 -			ctrl = eor | len | DescOwn | IPCS | UDPCS | TCPCS;
   2.682 -#else
   2.683 -			ctrl = eor | len | DescOwn;
   2.684 -#endif
   2.685 -			if (frag == skb_shinfo(skb)->nr_frags - 1)
   2.686 -				ctrl |= LastFrag;
   2.687 -
   2.688 -			txd = &cp->tx_ring[entry];
   2.689 -			txd->opts2 = 0;
   2.690 -			txd->addr_lo = cpu_to_le32(mapping);
   2.691 -			wmb();
   2.692 -
   2.693 -			txd->opts1 = cpu_to_le32(ctrl);
   2.694 -			wmb();
   2.695 -
   2.696 -			cp->tx_skb[entry].skb = skb;
   2.697 -			cp->tx_skb[entry].mapping = mapping;
   2.698 -			cp->tx_skb[entry].frag = frag + 2;
   2.699 -			entry = NEXT_TX(entry);
   2.700 -		}
   2.701 -
   2.702 -		txd = &cp->tx_ring[first_entry];
   2.703 -		txd->opts2 = 0;
   2.704 -		txd->addr_lo = cpu_to_le32(first_mapping);
   2.705 -		wmb();
   2.706 -
   2.707 -#ifdef CP_TX_CHECKSUM
   2.708 -		txd->opts1 = cpu_to_le32(first_len | FirstFrag | DescOwn | IPCS | UDPCS | TCPCS);
   2.709 -#else
   2.710 -		txd->opts1 = cpu_to_le32(first_len | FirstFrag | DescOwn);
   2.711 -#endif
   2.712 -		wmb();
   2.713 -	}
   2.714 -	cp->tx_head = entry;
   2.715 -	if (netif_msg_tx_queued(cp))
   2.716 -		printk(KERN_DEBUG "%s: tx queued, slot %d, skblen %d\n",
   2.717 -		       dev->name, entry, skb->len);
   2.718 -	if (TX_BUFFS_AVAIL(cp) < 0)
   2.719 -		BUG();
   2.720 -	if (TX_BUFFS_AVAIL(cp) == 0)
   2.721 -		netif_stop_queue(dev);
   2.722 -
   2.723 -	spin_unlock_irq(&cp->lock);
   2.724 -
   2.725 -	cpw8(TxPoll, NormalTxPoll);
   2.726 -	dev->trans_start = jiffies;
   2.727 -
   2.728 -	return 0;
   2.729 -}
   2.730 -
   2.731 -/* Set or clear the multicast filter for this adaptor.
   2.732 -   This routine is not state sensitive and need not be SMP locked. */
   2.733 -
   2.734 -static unsigned const ethernet_polynomial = 0x04c11db7U;
   2.735 -static inline u32 ether_crc (int length, unsigned char *data)
   2.736 -{
   2.737 -	int crc = -1;
   2.738 -
   2.739 -	while (--length >= 0) {
   2.740 -		unsigned char current_octet = *data++;
   2.741 -		int bit;
   2.742 -		for (bit = 0; bit < 8; bit++, current_octet >>= 1)
   2.743 -			crc = (crc << 1) ^ ((crc < 0) ^ (current_octet & 1) ?
   2.744 -			     ethernet_polynomial : 0);
   2.745 -	}
   2.746 -
   2.747 -	return crc;
   2.748 -}
   2.749 -
   2.750 -static void __cp_set_rx_mode (struct net_device *dev)
   2.751 -{
   2.752 -	struct cp_private *cp = dev->priv;
   2.753 -	u32 mc_filter[2];	/* Multicast hash filter */
   2.754 -	int i, rx_mode;
   2.755 -	u32 tmp;
   2.756 -
   2.757 -	/* Note: do not reorder, GCC is clever about common statements. */
   2.758 -	if (dev->flags & IFF_PROMISC) {
   2.759 -		/* Unconditionally log net taps. */
   2.760 -		printk (KERN_NOTICE "%s: Promiscuous mode enabled.\n",
   2.761 -			dev->name);
   2.762 -		rx_mode =
   2.763 -		    AcceptBroadcast | AcceptMulticast | AcceptMyPhys |
   2.764 -		    AcceptAllPhys;
   2.765 -		mc_filter[1] = mc_filter[0] = 0xffffffff;
   2.766 -	} else if ((dev->mc_count > multicast_filter_limit)
   2.767 -		   || (dev->flags & IFF_ALLMULTI)) {
   2.768 -		/* Too many to filter perfectly -- accept all multicasts. */
   2.769 -		rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
   2.770 -		mc_filter[1] = mc_filter[0] = 0xffffffff;
   2.771 -	} else {
   2.772 -		struct dev_mc_list *mclist;
   2.773 -		rx_mode = AcceptBroadcast | AcceptMyPhys;
   2.774 -		mc_filter[1] = mc_filter[0] = 0;
   2.775 -		for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
   2.776 -		     i++, mclist = mclist->next) {
   2.777 -			int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
   2.778 -
   2.779 -			mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
   2.780 -			rx_mode |= AcceptMulticast;
   2.781 -		}
   2.782 -	}
   2.783 -
   2.784 -	/* We can safely update without stopping the chip. */
   2.785 -	tmp = cp_rx_config | rx_mode;
   2.786 -	if (cp->rx_config != tmp) {
   2.787 -		cpw32_f (RxConfig, tmp);
   2.788 -		cp->rx_config = tmp;
   2.789 -	}
   2.790 -	cpw32_f (MAR0 + 0, mc_filter[0]);
   2.791 -	cpw32_f (MAR0 + 4, mc_filter[1]);
   2.792 -}
   2.793 -
   2.794 -static void cp_set_rx_mode (struct net_device *dev)
   2.795 -{
   2.796 -	unsigned long flags;
   2.797 -	struct cp_private *cp = dev->priv;
   2.798 -
   2.799 -	spin_lock_irqsave (&cp->lock, flags);
   2.800 -	__cp_set_rx_mode(dev);
   2.801 -	spin_unlock_irqrestore (&cp->lock, flags);
   2.802 -}
   2.803 -
   2.804 -static void __cp_get_stats(struct cp_private *cp)
   2.805 -{
   2.806 -	/* XXX implement */
   2.807 -}
   2.808 -
   2.809 -static struct net_device_stats *cp_get_stats(struct net_device *dev)
   2.810 -{
   2.811 -	struct cp_private *cp = dev->priv;
   2.812 -
   2.813 -	/* The chip only need report frame silently dropped. */
   2.814 -	spin_lock_irq(&cp->lock);
   2.815 - 	if (netif_running(dev) && netif_device_present(dev))
   2.816 - 		__cp_get_stats(cp);
   2.817 -	spin_unlock_irq(&cp->lock);
   2.818 -
   2.819 -	return &cp->net_stats;
   2.820 -}
   2.821 -
   2.822 -static void cp_stop_hw (struct cp_private *cp)
   2.823 -{
   2.824 -	cpw16(IntrMask, 0);
   2.825 -	cpr16(IntrMask);
   2.826 -	cpw8(Cmd, 0);
   2.827 -	cpw16(CpCmd, 0);
   2.828 -	cpr16(CpCmd);
   2.829 -	cpw16(IntrStatus, ~(cpr16(IntrStatus)));
   2.830 -	synchronize_irq();
   2.831 -	udelay(10);
   2.832 -
   2.833 -	cp->rx_tail = 0;
   2.834 -	cp->tx_head = cp->tx_tail = 0;
   2.835 -}
   2.836 -
   2.837 -static void cp_reset_hw (struct cp_private *cp)
   2.838 -{
   2.839 -	unsigned work = 1000;
   2.840 -
   2.841 -	cpw8(Cmd, CmdReset);
   2.842 -
   2.843 -	while (work--) {
   2.844 -		if (!(cpr8(Cmd) & CmdReset))
   2.845 -			return;
   2.846 -
   2.847 -		set_current_state(TASK_UNINTERRUPTIBLE);
   2.848 -		schedule_timeout(10);
   2.849 -	}
   2.850 -
   2.851 -	printk(KERN_ERR "%s: hardware reset timeout\n", cp->dev->name);
   2.852 -}
   2.853 -
   2.854 -static void cp_init_hw (struct cp_private *cp)
   2.855 -{
   2.856 -	struct net_device *dev = cp->dev;
   2.857 -
   2.858 -	cp_reset_hw(cp);
   2.859 -
   2.860 -	cpw8_f (Cfg9346, Cfg9346_Unlock);
   2.861 -
   2.862 -	/* Restore our idea of the MAC address. */
   2.863 -	cpw32_f (MAC0 + 0, cpu_to_le32 (*(u32 *) (dev->dev_addr + 0)));
   2.864 -	cpw32_f (MAC0 + 4, cpu_to_le32 (*(u32 *) (dev->dev_addr + 4)));
   2.865 -
   2.866 -	cpw8(Cmd, RxOn | TxOn);
   2.867 -	cpw16(CpCmd, PCIMulRW | CpRxOn | CpTxOn);
   2.868 -	cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */
   2.869 -
   2.870 -	__cp_set_rx_mode(dev);
   2.871 -	cpw32_f (TxConfig, IFG | (TX_DMA_BURST << TxDMAShift));
   2.872 -
   2.873 -	cpw8(Config1, cpr8(Config1) | DriverLoaded | PMEnable);
   2.874 -	cpw8(Config3, PARMEnable); /* disables magic packet and WOL */
   2.875 -	cpw8(Config5, cpr8(Config5) & PMEStatus); /* disables more WOL stuff */
   2.876 -
   2.877 -	cpw32_f(HiTxRingAddr, 0);
   2.878 -	cpw32_f(HiTxRingAddr + 4, 0);
   2.879 -	cpw32_f(OldRxBufAddr, 0);
   2.880 -	cpw32_f(OldTSD0, 0);
   2.881 -	cpw32_f(OldTSD0 + 4, 0);
   2.882 -	cpw32_f(OldTSD0 + 8, 0);
   2.883 -	cpw32_f(OldTSD0 + 12, 0);
   2.884 -
   2.885 -	cpw32_f(RxRingAddr, cp->ring_dma);
   2.886 -	cpw32_f(RxRingAddr + 4, 0);
   2.887 -	cpw32_f(TxRingAddr, cp->ring_dma + (sizeof(struct cp_desc) * CP_RX_RING_SIZE));
   2.888 -	cpw32_f(TxRingAddr + 4, 0);
   2.889 -
   2.890 -	cpw16(MultiIntr, 0);
   2.891 -
   2.892 -	cpw16(IntrMask, cp_intr_mask);
   2.893 -
   2.894 -	cpw8_f (Cfg9346, Cfg9346_Lock);
   2.895 -}
   2.896 -
   2.897 -static int cp_refill_rx (struct cp_private *cp)
   2.898 -{
   2.899 -	unsigned i;
   2.900 -
   2.901 -	for (i = 0; i < CP_RX_RING_SIZE; i++) {
   2.902 -		struct sk_buff *skb;
   2.903 -
   2.904 -		skb = dev_alloc_skb(cp->rx_buf_sz + RX_OFFSET);
   2.905 -		if (!skb)
   2.906 -			goto err_out;
   2.907 -
   2.908 -		skb->dev = cp->dev;
   2.909 -		skb_reserve(skb, RX_OFFSET);
   2.910 -		skb_put(skb, cp->rx_buf_sz);
   2.911 -
   2.912 -		cp->rx_skb[i].mapping = pci_map_single(cp->pdev,
   2.913 -			skb->data, cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
   2.914 -		cp->rx_skb[i].skb = skb;
   2.915 -		cp->rx_skb[i].frag = 0;
   2.916 -
   2.917 -		if (i == (CP_RX_RING_SIZE - 1))
   2.918 -			cp->rx_ring[i].opts1 =
   2.919 -				cpu_to_le32(DescOwn | RingEnd | cp->rx_buf_sz);
   2.920 -		else
   2.921 -			cp->rx_ring[i].opts1 =
   2.922 -				cpu_to_le32(DescOwn | cp->rx_buf_sz);
   2.923 -		cp->rx_ring[i].opts2 = 0;
   2.924 -		cp->rx_ring[i].addr_lo = cpu_to_le32(cp->rx_skb[i].mapping);
   2.925 -		cp->rx_ring[i].addr_hi = 0;
   2.926 -	}
   2.927 -
   2.928 -	return 0;
   2.929 -
   2.930 -err_out:
   2.931 -	cp_clean_rings(cp);
   2.932 -	return -ENOMEM;
   2.933 -}
   2.934 -
   2.935 -static int cp_init_rings (struct cp_private *cp)
   2.936 -{
   2.937 -	memset(cp->tx_ring, 0, sizeof(struct cp_desc) * CP_TX_RING_SIZE);
   2.938 -	cp->tx_ring[CP_TX_RING_SIZE - 1].opts1 = cpu_to_le32(RingEnd);
   2.939 -
   2.940 -	cp->rx_tail = 0;
   2.941 -	cp->tx_head = cp->tx_tail = 0;
   2.942 -
   2.943 -	return cp_refill_rx (cp);
   2.944 -}
   2.945 -
   2.946 -static int cp_alloc_rings (struct cp_private *cp)
   2.947 -{
   2.948 -	cp->rx_ring = pci_alloc_consistent(cp->pdev, CP_RING_BYTES, &cp->ring_dma);
   2.949 -	if (!cp->rx_ring)
   2.950 -		return -ENOMEM;
   2.951 -	cp->tx_ring = &cp->rx_ring[CP_RX_RING_SIZE];
   2.952 -	return cp_init_rings(cp);
   2.953 -}
   2.954 -
   2.955 -static void cp_clean_rings (struct cp_private *cp)
   2.956 -{
   2.957 -	unsigned i;
   2.958 -
   2.959 -	memset(cp->rx_ring, 0, sizeof(struct cp_desc) * CP_RX_RING_SIZE);
   2.960 -	memset(cp->tx_ring, 0, sizeof(struct cp_desc) * CP_TX_RING_SIZE);
   2.961 -
   2.962 -	for (i = 0; i < CP_RX_RING_SIZE; i++) {
   2.963 -		if (cp->rx_skb[i].skb) {
   2.964 -			pci_unmap_single(cp->pdev, cp->rx_skb[i].mapping,
   2.965 -					 cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
   2.966 -			dev_kfree_skb(cp->rx_skb[i].skb);
   2.967 -		}
   2.968 -	}
   2.969 -
   2.970 -	for (i = 0; i < CP_TX_RING_SIZE; i++) {
   2.971 -		if (cp->tx_skb[i].skb) {
   2.972 -			struct sk_buff *skb = cp->tx_skb[i].skb;
   2.973 -			pci_unmap_single(cp->pdev, cp->tx_skb[i].mapping,
   2.974 -					 skb->len, PCI_DMA_TODEVICE);
   2.975 -			dev_kfree_skb(skb);
   2.976 -			cp->net_stats.tx_dropped++;
   2.977 -		}
   2.978 -	}
   2.979 -
   2.980 -	memset(&cp->rx_skb, 0, sizeof(struct ring_info) * CP_RX_RING_SIZE);
   2.981 -	memset(&cp->tx_skb, 0, sizeof(struct ring_info) * CP_TX_RING_SIZE);
   2.982 -}
   2.983 -
   2.984 -static void cp_free_rings (struct cp_private *cp)
   2.985 -{
   2.986 -	cp_clean_rings(cp);
   2.987 -	pci_free_consistent(cp->pdev, CP_RING_BYTES, cp->rx_ring, cp->ring_dma);
   2.988 -	cp->rx_ring = NULL;
   2.989 -	cp->tx_ring = NULL;
   2.990 -}
   2.991 -
   2.992 -static int cp_open (struct net_device *dev)
   2.993 -{
   2.994 -	struct cp_private *cp = dev->priv;
   2.995 -	int rc;
   2.996 -
   2.997 -	if (netif_msg_ifup(cp))
   2.998 -		printk(KERN_DEBUG "%s: enabling interface\n", dev->name);
   2.999 -
  2.1000 -	cp->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32);
  2.1001 -
  2.1002 -	rc = cp_alloc_rings(cp);
  2.1003 -	if (rc)
  2.1004 -		return rc;
  2.1005 -
  2.1006 -	cp_init_hw(cp);
  2.1007 -
  2.1008 -	rc = request_irq(dev->irq, cp_interrupt, SA_SHIRQ, dev->name, dev);
  2.1009 -	if (rc)
  2.1010 -		goto err_out_hw;
  2.1011 -
  2.1012 -	netif_start_queue(dev);
  2.1013 -
  2.1014 -	return 0;
  2.1015 -
  2.1016 -err_out_hw:
  2.1017 -	cp_stop_hw(cp);
  2.1018 -	cp_free_rings(cp);
  2.1019 -	return rc;
  2.1020 -}
  2.1021 -
  2.1022 -static int cp_close (struct net_device *dev)
  2.1023 -{
  2.1024 -	struct cp_private *cp = dev->priv;
  2.1025 -
  2.1026 -	if (netif_msg_ifdown(cp))
  2.1027 -		printk(KERN_DEBUG "%s: disabling interface\n", dev->name);
  2.1028 -
  2.1029 -	netif_stop_queue(dev);
  2.1030 -	cp_stop_hw(cp);
  2.1031 -	free_irq(dev->irq, dev);
  2.1032 -	cp_free_rings(cp);
  2.1033 -	return 0;
  2.1034 -}
  2.1035 -
  2.1036 -static int cp_ethtool_ioctl (struct cp_private *cp, void *useraddr)
  2.1037 -{
  2.1038 -	u32 ethcmd;
  2.1039 -
  2.1040 -	/* dev_ioctl() in ../../net/core/dev.c has already checked
  2.1041 -	   capable(CAP_NET_ADMIN), so don't bother with that here.  */
  2.1042 -
  2.1043 -	if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
  2.1044 -		return -EFAULT;
  2.1045 -
  2.1046 -	switch (ethcmd) {
  2.1047 -
  2.1048 -	case ETHTOOL_GDRVINFO:
  2.1049 -		{
  2.1050 -			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
  2.1051 -			strcpy (info.driver, DRV_NAME);
  2.1052 -			strcpy (info.version, DRV_VERSION);
  2.1053 -			strcpy (info.bus_info, cp->pdev->slot_name);
  2.1054 -			if (copy_to_user (useraddr, &info, sizeof (info)))
  2.1055 -				return -EFAULT;
  2.1056 -			return 0;
  2.1057 -		}
  2.1058 -
  2.1059 -	default:
  2.1060 -		break;
  2.1061 -	}
  2.1062 -
  2.1063 -	return -EOPNOTSUPP;
  2.1064 -}
  2.1065 -
  2.1066 -
  2.1067 -static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
  2.1068 -{
  2.1069 -	struct cp_private *cp = dev->priv;
  2.1070 -	int rc = 0;
  2.1071 -
  2.1072 -	switch (cmd) {
  2.1073 -	case SIOCETHTOOL:
  2.1074 -		return cp_ethtool_ioctl(cp, (void *) rq->ifr_data);
  2.1075 -
  2.1076 -	default:
  2.1077 -		rc = -EOPNOTSUPP;
  2.1078 -		break;
  2.1079 -	}
  2.1080 -
  2.1081 -	return rc;
  2.1082 -}
  2.1083 -
  2.1084 -
  2.1085 -
  2.1086 -/* Serial EEPROM section. */
  2.1087 -
  2.1088 -/*  EEPROM_Ctrl bits. */
  2.1089 -#define EE_SHIFT_CLK	0x04	/* EEPROM shift clock. */
  2.1090 -#define EE_CS			0x08	/* EEPROM chip select. */
  2.1091 -#define EE_DATA_WRITE	0x02	/* EEPROM chip data in. */
  2.1092 -#define EE_WRITE_0		0x00
  2.1093 -#define EE_WRITE_1		0x02
  2.1094 -#define EE_DATA_READ	0x01	/* EEPROM chip data out. */
  2.1095 -#define EE_ENB			(0x80 | EE_CS)
  2.1096 -
  2.1097 -/* Delay between EEPROM clock transitions.
  2.1098 -   No extra delay is needed with 33Mhz PCI, but 66Mhz may change this.
  2.1099 - */
  2.1100 -
  2.1101 -#define eeprom_delay()	readl(ee_addr)
  2.1102 -
  2.1103 -/* The EEPROM commands include the alway-set leading bit. */
  2.1104 -#define EE_WRITE_CMD	(5)
  2.1105 -#define EE_READ_CMD		(6)
  2.1106 -#define EE_ERASE_CMD	(7)
  2.1107 -
  2.1108 -static int __devinit read_eeprom (void *ioaddr, int location, int addr_len)
  2.1109 -{
  2.1110 -	int i;
  2.1111 -	unsigned retval = 0;
  2.1112 -	void *ee_addr = ioaddr + Cfg9346;
  2.1113 -	int read_cmd = location | (EE_READ_CMD << addr_len);
  2.1114 -
  2.1115 -	writeb (EE_ENB & ~EE_CS, ee_addr);
  2.1116 -	writeb (EE_ENB, ee_addr);
  2.1117 -	eeprom_delay ();
  2.1118 -
  2.1119 -	/* Shift the read command bits out. */
  2.1120 -	for (i = 4 + addr_len; i >= 0; i--) {
  2.1121 -		int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
  2.1122 -		writeb (EE_ENB | dataval, ee_addr);
  2.1123 -		eeprom_delay ();
  2.1124 -		writeb (EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
  2.1125 -		eeprom_delay ();
  2.1126 -	}
  2.1127 -	writeb (EE_ENB, ee_addr);
  2.1128 -	eeprom_delay ();
  2.1129 -
  2.1130 -	for (i = 16; i > 0; i--) {
  2.1131 -		writeb (EE_ENB | EE_SHIFT_CLK, ee_addr);
  2.1132 -		eeprom_delay ();
  2.1133 -		retval =
  2.1134 -		    (retval << 1) | ((readb (ee_addr) & EE_DATA_READ) ? 1 :
  2.1135 -				     0);
  2.1136 -		writeb (EE_ENB, ee_addr);
  2.1137 -		eeprom_delay ();
  2.1138 -	}
  2.1139 -
  2.1140 -	/* Terminate the EEPROM access. */
  2.1141 -	writeb (~EE_CS, ee_addr);
  2.1142 -	eeprom_delay ();
  2.1143 -
  2.1144 -	return retval;
  2.1145 -}
  2.1146 -
  2.1147 -static int __devinit cp_init_one (struct pci_dev *pdev,
  2.1148 -				  const struct pci_device_id *ent)
  2.1149 -{
  2.1150 -	struct net_device *dev;
  2.1151 -	struct cp_private *cp;
  2.1152 -	int rc;
  2.1153 -	void *regs;
  2.1154 -	long pciaddr;
  2.1155 -	unsigned addr_len, i;
  2.1156 -	u8 pci_rev, cache_size;
  2.1157 -	u16 pci_command;
  2.1158 -
  2.1159 -#ifndef MODULE
  2.1160 -	static int version_printed;
  2.1161 -	if (version_printed++ == 0)
  2.1162 -		printk("%s", version);
  2.1163 -#endif
  2.1164 -
  2.1165 -	pci_read_config_byte(pdev, PCI_REVISION_ID, &pci_rev);
  2.1166 -
  2.1167 -	if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
  2.1168 -	    pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev < 0x20) {
  2.1169 -		printk(KERN_ERR PFX "pci dev %s (id %04x:%04x rev %02x) is not an 8139C+ compatible chip\n",
  2.1170 -		       pdev->slot_name, pdev->vendor, pdev->device, pci_rev);
  2.1171 -		printk(KERN_ERR PFX "Ensure the \"8139too\" driver is installed!\n");
  2.1172 -		return -ENODEV;
  2.1173 -	}
  2.1174 -
  2.1175 -	dev = alloc_etherdev(sizeof(struct cp_private));
  2.1176 -	if (!dev)
  2.1177 -		return -ENOMEM;
  2.1178 -	SET_MODULE_OWNER(dev);
  2.1179 -	cp = dev->priv;
  2.1180 -	cp->pdev = pdev;
  2.1181 -	cp->dev = dev;
  2.1182 -	cp->msg_enable = (debug < 0 ? CP_DEF_MSG_ENABLE : debug);
  2.1183 -	spin_lock_init (&cp->lock);
  2.1184 -
  2.1185 -	rc = pci_enable_device(pdev);
  2.1186 -	if (rc)
  2.1187 -		goto err_out_free;
  2.1188 -
  2.1189 -	rc = pci_request_regions(pdev, DRV_NAME);
  2.1190 -	if (rc)
  2.1191 -		goto err_out_disable;
  2.1192 -
  2.1193 -	if (pdev->irq < 2) {
  2.1194 -		rc = -EIO;
  2.1195 -		printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n",
  2.1196 -		       pdev->irq, pdev->slot_name);
  2.1197 -		goto err_out_res;
  2.1198 -	}
  2.1199 -	pciaddr = pci_resource_start(pdev, 1);
  2.1200 -	if (!pciaddr) {
  2.1201 -		rc = -EIO;
  2.1202 -		printk(KERN_ERR PFX "no MMIO resource for pci dev %s\n",
  2.1203 -		       pdev->slot_name);
  2.1204 -		goto err_out_res;
  2.1205 -	}
  2.1206 -	if (pci_resource_len(pdev, 1) < CP_REGS_SIZE) {
  2.1207 -		rc = -EIO;
  2.1208 -		printk(KERN_ERR PFX "MMIO resource (%lx) too small on pci dev %s\n",
  2.1209 -		       pci_resource_len(pdev, 1), pdev->slot_name);
  2.1210 -		goto err_out_res;
  2.1211 -	}
  2.1212 -
  2.1213 -	regs = ioremap_nocache(pciaddr, CP_REGS_SIZE);
  2.1214 -	if (!regs) {
  2.1215 -		rc = -EIO;
  2.1216 -		printk(KERN_ERR PFX "Cannot map PCI MMIO (%lx@%lx) on pci dev %s\n",
  2.1217 -		       pci_resource_len(pdev, 1), pciaddr, pdev->slot_name);
  2.1218 -		goto err_out_res;
  2.1219 -	}
  2.1220 -	dev->base_addr = (unsigned long) regs;
  2.1221 -	cp->regs = regs;
  2.1222 -
  2.1223 -	cp_stop_hw(cp);
  2.1224 -
  2.1225 -	/* read MAC address from EEPROM */
  2.1226 -	addr_len = read_eeprom (regs, 0, 8) == 0x8129 ? 8 : 6;
  2.1227 -	for (i = 0; i < 3; i++)
  2.1228 -		((u16 *) (dev->dev_addr))[i] =
  2.1229 -		    le16_to_cpu (read_eeprom (regs, i + 7, addr_len));
  2.1230 -
  2.1231 -	dev->open = cp_open;
  2.1232 -	dev->stop = cp_close;
  2.1233 -	dev->set_multicast_list = cp_set_rx_mode;
  2.1234 -	dev->hard_start_xmit = cp_start_xmit;
  2.1235 -	dev->get_stats = cp_get_stats;
  2.1236 -	dev->do_ioctl = cp_ioctl;
  2.1237 -#if 0
  2.1238 -	dev->tx_timeout = cp_tx_timeout;
  2.1239 -	dev->watchdog_timeo = TX_TIMEOUT;
  2.1240 -#endif
  2.1241 -#ifdef CP_TX_CHECKSUM
  2.1242 -	dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
  2.1243 -#endif
  2.1244 -
  2.1245 -	dev->irq = pdev->irq;
  2.1246 -
  2.1247 -	rc = register_netdev(dev);
  2.1248 -	if (rc)
  2.1249 -		goto err_out_iomap;
  2.1250 -
  2.1251 -	printk (KERN_INFO "%s: %s at 0x%lx, "
  2.1252 -		"%02x:%02x:%02x:%02x:%02x:%02x, "
  2.1253 -		"IRQ %d\n",
  2.1254 -		dev->name,
  2.1255 -		"RTL-8139C+",
  2.1256 -		dev->base_addr,
  2.1257 -		dev->dev_addr[0], dev->dev_addr[1],
  2.1258 -		dev->dev_addr[2], dev->dev_addr[3],
  2.1259 -		dev->dev_addr[4], dev->dev_addr[5],
  2.1260 -		dev->irq);
  2.1261 -
  2.1262 -	pci_set_drvdata(pdev, dev);
  2.1263 -
  2.1264 -	/*
  2.1265 -	 * Looks like this is necessary to deal with on all architectures,
  2.1266 -	 * even this %$#%$# N440BX Intel based thing doesn't get it right.
  2.1267 -	 * Ie. having two NICs in the machine, one will have the cache
  2.1268 -	 * line set at boot time, the other will not.
  2.1269 -	 */
  2.1270 -	pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_size);
  2.1271 -	cache_size <<= 2;
  2.1272 -	if (cache_size != SMP_CACHE_BYTES) {
  2.1273 -		printk(KERN_INFO "%s: PCI cache line size set incorrectly "
  2.1274 -		       "(%i bytes) by BIOS/FW, ", dev->name, cache_size);
  2.1275 -		if (cache_size > SMP_CACHE_BYTES)
  2.1276 -			printk("expecting %i\n", SMP_CACHE_BYTES);
  2.1277 -		else {
  2.1278 -			printk("correcting to %i\n", SMP_CACHE_BYTES);
  2.1279 -			pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
  2.1280 -					      SMP_CACHE_BYTES >> 2);
  2.1281 -		}
  2.1282 -	}
  2.1283 -
  2.1284 -	/* enable busmastering and memory-write-invalidate */
  2.1285 -	pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
  2.1286 -	if (!(pci_command & PCI_COMMAND_INVALIDATE)) {
  2.1287 -		pci_command |= PCI_COMMAND_INVALIDATE;
  2.1288 -		pci_write_config_word(pdev, PCI_COMMAND, pci_command);
  2.1289 -	}
  2.1290 -	pci_set_master(pdev);
  2.1291 -
  2.1292 -	return 0;
  2.1293 -
  2.1294 -err_out_iomap:
  2.1295 -	iounmap(regs);
  2.1296 -err_out_res:
  2.1297 -	pci_release_regions(pdev);
  2.1298 -err_out_disable:
  2.1299 -	pci_disable_device(pdev);
  2.1300 -err_out_free:
  2.1301 -	kfree(dev);
  2.1302 -	return rc;
  2.1303 -}
  2.1304 -
  2.1305 -static void __devexit cp_remove_one (struct pci_dev *pdev)
  2.1306 -{
  2.1307 -	struct net_device *dev = pci_get_drvdata(pdev);
  2.1308 -	struct cp_private *cp = dev->priv;
  2.1309 -
  2.1310 -	if (!dev)
  2.1311 -		BUG();
  2.1312 -	unregister_netdev(dev);
  2.1313 -	iounmap(cp->regs);
  2.1314 -	pci_release_regions(pdev);
  2.1315 -	pci_disable_device(pdev);
  2.1316 -	pci_set_drvdata(pdev, NULL);
  2.1317 -	kfree(dev);
  2.1318 -}
  2.1319 -
  2.1320 -static struct pci_driver cp_driver = {
  2.1321 -	name:		DRV_NAME,
  2.1322 -	id_table:	cp_pci_tbl,
  2.1323 -	probe:		cp_init_one,
  2.1324 -	remove:		__devexit_p(cp_remove_one),
  2.1325 -};
  2.1326 -
  2.1327 -static int __init cp_init (void)
  2.1328 -{
  2.1329 -#ifdef MODULE
  2.1330 -	printk("%s", version);
  2.1331 -#endif
  2.1332 -	return pci_module_init (&cp_driver);
  2.1333 -}
  2.1334 -
  2.1335 -static void __exit cp_exit (void)
  2.1336 -{
  2.1337 -	pci_unregister_driver (&cp_driver);
  2.1338 -}
  2.1339 -
  2.1340 -module_init(cp_init);
  2.1341 -module_exit(cp_exit);
     3.1 --- a/xen-2.4.16/drivers/net/Makefile	Fri Feb 14 17:11:31 2003 +0000
     3.2 +++ b/xen-2.4.16/drivers/net/Makefile	Fri Feb 14 17:31:12 2003 +0000
     3.3 @@ -3,13 +3,11 @@ include $(BASEDIR)/Rules.mk
     3.4  
     3.5  default: $(OBJS)
     3.6  	$(MAKE) -C ne
     3.7 -	$(MAKE) -C tulip
     3.8  	$(MAKE) -C e1000
     3.9 -	$(LD) -r -o driver.o e1000/e1000.o $(OBJS) tulip/tulip.o ne/ne_drv.o
    3.10 +	$(LD) -r -o driver.o e1000/e1000.o $(OBJS) ne/ne_drv.o
    3.11  
    3.12  clean:
    3.13  	$(MAKE) -C ne clean
    3.14 -	$(MAKE) -C tulip clean
    3.15  	rm -f *.o *~ core
    3.16  
    3.17  .PHONY: default clean
     4.1 --- a/xen-2.4.16/drivers/net/e1000/e1000_osdep.h	Fri Feb 14 17:11:31 2003 +0000
     4.2 +++ b/xen-2.4.16/drivers/net/e1000/e1000_osdep.h	Fri Feb 14 17:31:12 2003 +0000
     4.3 @@ -69,7 +69,6 @@ typedef enum {
     4.4      TRUE = 1
     4.5  } boolean_t;
     4.6  
     4.7 -#define ASSERT(x)	if(!(x)) BUG()
     4.8  #define MSGOUT(S, A, B)	printk(KERN_DEBUG S "\n", A, B)
     4.9  
    4.10  //#define DBG 1
     5.1 --- a/xen-2.4.16/drivers/net/eepro100.c	Fri Feb 14 17:11:31 2003 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,2312 +0,0 @@
     5.4 -/* drivers/net/eepro100.c: An Intel i82557-559 Ethernet driver for Linux. */
     5.5 -/*
     5.6 -   NOTICE: For use with late 2.3 kernels only.
     5.7 -   May not compile for kernels 2.3.43-47.
     5.8 -	Written 1996-1999 by Donald Becker.
     5.9 -
    5.10 -	The driver also contains updates by different kernel developers
    5.11 -	(see incomplete list below).
    5.12 -	Current maintainer is Andrey V. Savochkin <saw@saw.sw.com.sg>.
    5.13 -	Please use this email address and linux-kernel mailing list for bug reports.
    5.14 -
    5.15 -	This software may be used and distributed according to the terms
    5.16 -	of the GNU General Public License, incorporated herein by reference.
    5.17 -
    5.18 -	This driver is for the Intel EtherExpress Pro100 (Speedo3) design.
    5.19 -	It should work with all i82557/558/559 boards.
    5.20 -
    5.21 -	Version history:
    5.22 -	1998 Apr - 2000 Feb  Andrey V. Savochkin <saw@saw.sw.com.sg>
    5.23 -		Serious fixes for multicast filter list setting, TX timeout routine;
    5.24 -		RX ring refilling logic;  other stuff
    5.25 -	2000 Feb  Jeff Garzik <jgarzik@mandrakesoft.com>
    5.26 -		Convert to new PCI driver interface
    5.27 -	2000 Mar 24  Dragan Stancevic <visitor@valinux.com>
    5.28 -		Disabled FC and ER, to avoid lockups when when we get FCP interrupts.
    5.29 -	2000 Jul 17 Goutham Rao <goutham.rao@intel.com>
    5.30 -		PCI DMA API fixes, adding pci_dma_sync_single calls where neccesary
    5.31 -*/
    5.32 -
    5.33 -static const char *version =
    5.34 -"eepro100.c:v1.09j-t 9/29/99 Donald Becker http://cesdis.gsfc.nasa.gov/linux/drivers/eepro100.html\n"
    5.35 -"eepro100.c: $Revision: 1.36 $ 2000/11/17 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n";
    5.36 -
    5.37 -/* A few user-configurable values that apply to all boards.
    5.38 -   First set is undocumented and spelled per Intel recommendations. */
    5.39 -
    5.40 -static int congenb /* = 0 */; /* Enable congestion control in the DP83840. */
    5.41 -static int txfifo = 8;		/* Tx FIFO threshold in 4 byte units, 0-15 */
    5.42 -static int rxfifo = 8;		/* Rx FIFO threshold, default 32 bytes. */
    5.43 -/* Tx/Rx DMA burst length, 0-127, 0 == no preemption, tx==128 -> disabled. */
    5.44 -static int txdmacount = 128;
    5.45 -static int rxdmacount /* = 0 */;
    5.46 -
    5.47 -/* Set the copy breakpoint for the copy-only-tiny-buffer Rx method.
    5.48 -   Lower values use more memory, but are faster. */
    5.49 -/*#if defined(__alpha__) || defined(__sparc__) || defined(__mips__) || \
    5.50 -    defined(__arm__)
    5.51 -static int rx_copybreak = 1518;
    5.52 -#else
    5.53 -static int rx_copybreak = 200;
    5.54 -#endif*/
    5.55 -
    5.56 -/* Xen doesn't do rx_copybreak in drivers. */
    5.57 -static int rx_copybreak = 0;
    5.58 -
    5.59 -/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
    5.60 -static int max_interrupt_work = 20;
    5.61 -
    5.62 -/* Maximum number of multicast addresses to filter (vs. rx-all-multicast) */
    5.63 -static int multicast_filter_limit = 64;
    5.64 -
    5.65 -/* 'options' is used to pass a transceiver override or full-duplex flag
    5.66 -   e.g. "options=16" for FD, "options=32" for 100mbps-only. */
    5.67 -static int full_duplex[] = {-1, -1, -1, -1, -1, -1, -1, -1};
    5.68 -static int options[] = {-1, -1, -1, -1, -1, -1, -1, -1};
    5.69 -static int debug = -1;			/* The debug level */
    5.70 -
    5.71 -#if !defined(__OPTIMIZE__)  ||  !defined(__KERNEL__)
    5.72 -#warning  You must compile this file with the correct options!
    5.73 -#warning  See the last lines of the source file.
    5.74 -#error You must compile this driver with "-O".
    5.75 -#endif
    5.76 -
    5.77 -#include <linux/config.h>
    5.78 -#include <linux/lib.h>
    5.79 -//#include <linux/version.h>
    5.80 -#include <linux/module.h>
    5.81 -
    5.82 -//#include <linux/kernel.h>
    5.83 -//#include <linux/string.h>
    5.84 -#include <linux/errno.h>
    5.85 -#include <linux/ioport.h>
    5.86 -#include <linux/slab.h>
    5.87 -#include <linux/interrupt.h>
    5.88 -#include <linux/timer.h>
    5.89 -#include <linux/pci.h>
    5.90 -#include <linux/spinlock.h>
    5.91 -#include <linux/init.h>
    5.92 -#include <linux/mii.h>
    5.93 -#include <linux/delay.h>
    5.94 -
    5.95 -#include <asm/bitops.h>
    5.96 -#include <asm/io.h>
    5.97 -#include <asm/uaccess.h>
    5.98 -
    5.99 -#include <linux/netdevice.h>
   5.100 -#include <linux/etherdevice.h>
   5.101 -#include <linux/skbuff.h>
   5.102 -#include <linux/ethtool.h>
   5.103 -#include <linux/delay.h>
   5.104 -
   5.105 -/* A few values that may be tweaked. */
   5.106 -
   5.107 -/* The ring sizes should be a power of two for efficiency. */
   5.108 -#undef RX_RING_SIZE
   5.109 -#undef TX_RING_SIZE
   5.110 -#define TX_RING_SIZE	32
   5.111 -#define RX_RING_SIZE	32
   5.112 -
   5.113 -/* How much slots multicast filter setup may take.
   5.114 -   Do not descrease without changing set_rx_mode() implementaion. */
   5.115 -#define TX_MULTICAST_SIZE   2
   5.116 -#define TX_MULTICAST_RESERV (TX_MULTICAST_SIZE*2)
   5.117 -/* Actual number of TX packets queued, must be
   5.118 -   <= TX_RING_SIZE-TX_MULTICAST_RESERV. */
   5.119 -#define TX_QUEUE_LIMIT  (TX_RING_SIZE-TX_MULTICAST_RESERV)
   5.120 -/* Hysteresis marking queue as no longer full. */
   5.121 -#define TX_QUEUE_UNFULL (TX_QUEUE_LIMIT-4)
   5.122 -
   5.123 -/* Operational parameters that usually are not changed. */
   5.124 -
   5.125 -/* Time in jiffies before concluding the transmitter is hung. */
   5.126 -#define TX_TIMEOUT		(2*HZ)
   5.127 -/* Size of an pre-allocated Rx buffer: <Ethernet MTU> + slack.*/
   5.128 -#define PKT_BUF_SZ		1536
   5.129 -
   5.130 -MODULE_AUTHOR("Maintainer: Andrey V. Savochkin <saw@saw.sw.com.sg>");
   5.131 -MODULE_DESCRIPTION("Intel i82557/i82558/i82559 PCI EtherExpressPro driver");
   5.132 -MODULE_LICENSE("GPL");
   5.133 -MODULE_PARM(debug, "i");
   5.134 -MODULE_PARM(options, "1-" __MODULE_STRING(8) "i");
   5.135 -MODULE_PARM(full_duplex, "1-" __MODULE_STRING(8) "i");
   5.136 -MODULE_PARM(congenb, "i");
   5.137 -MODULE_PARM(txfifo, "i");
   5.138 -MODULE_PARM(rxfifo, "i");
   5.139 -MODULE_PARM(txdmacount, "i");
   5.140 -MODULE_PARM(rxdmacount, "i");
   5.141 -MODULE_PARM(rx_copybreak, "i");
   5.142 -MODULE_PARM(max_interrupt_work, "i");
   5.143 -MODULE_PARM(multicast_filter_limit, "i");
   5.144 -MODULE_PARM_DESC(debug, "eepro100 debug level (0-6)");
   5.145 -MODULE_PARM_DESC(options, "eepro100: Bits 0-3: tranceiver type, bit 4: full duplex, bit 5: 100Mbps");
   5.146 -MODULE_PARM_DESC(full_duplex, "eepro100 full duplex setting(s) (1)");
   5.147 -MODULE_PARM_DESC(congenb, "eepro100  Enable congestion control (1)");
   5.148 -MODULE_PARM_DESC(txfifo, "eepro100 Tx FIFO threshold in 4 byte units, (0-15)");
   5.149 -MODULE_PARM_DESC(rxfifo, "eepro100 Rx FIFO threshold in 4 byte units, (0-15)");
   5.150 -MODULE_PARM_DESC(txdmaccount, "eepro100 Tx DMA burst length; 128 - disable (0-128)");
   5.151 -MODULE_PARM_DESC(rxdmaccount, "eepro100 Rx DMA burst length; 128 - disable (0-128)");
   5.152 -MODULE_PARM_DESC(rx_copybreak, "eepro100 copy breakpoint for copy-only-tiny-frames");
   5.153 -MODULE_PARM_DESC(max_interrupt_work, "eepro100 maximum events handled per interrupt");
   5.154 -MODULE_PARM_DESC(multicast_filter_limit, "eepro100 maximum number of filtered multicast addresses");
   5.155 -
   5.156 -#define RUN_AT(x) (jiffies + (x))
   5.157 -
   5.158 -/* ACPI power states don't universally work (yet) */
   5.159 -#ifndef CONFIG_PM
   5.160 -#define SET_POWER_STATE(_dev, _state) pci_set_power_state(_dev, 0)
   5.161 -#else
   5.162 -#define SET_POWER_STATE(_dev, _state) pci_set_power_state(_dev, _state)
   5.163 -#endif /* CONFIG_PM */
   5.164 -
   5.165 -#define netdevice_start(dev)
   5.166 -#define netdevice_stop(dev)
   5.167 -#define netif_set_tx_timeout(dev, tf, tm) \
   5.168 -								do { \
   5.169 -									(dev)->tx_timeout = (tf); \
   5.170 -									(dev)->watchdog_timeo = (tm); \
   5.171 -								} while(0)
   5.172 -
   5.173 -#ifndef PCI_DEVICE_ID_INTEL_ID1029
   5.174 -#define PCI_DEVICE_ID_INTEL_ID1029 0x1029
   5.175 -#endif
   5.176 -#ifndef PCI_DEVICE_ID_INTEL_ID1030
   5.177 -#define PCI_DEVICE_ID_INTEL_ID1030 0x1030
   5.178 -#endif
   5.179 -
   5.180 -
   5.181 -static int speedo_debug = 1;
   5.182 -
   5.183 -/*
   5.184 -				Theory of Operation
   5.185 -
   5.186 -I. Board Compatibility
   5.187 -
   5.188 -This device driver is designed for the Intel i82557 "Speedo3" chip, Intel's
   5.189 -single-chip fast Ethernet controller for PCI, as used on the Intel
   5.190 -EtherExpress Pro 100 adapter.
   5.191 -
   5.192 -II. Board-specific settings
   5.193 -
   5.194 -PCI bus devices are configured by the system at boot time, so no jumpers
   5.195 -need to be set on the board.  The system BIOS should be set to assign the
   5.196 -PCI INTA signal to an otherwise unused system IRQ line.  While it's
   5.197 -possible to share PCI interrupt lines, it negatively impacts performance and
   5.198 -only recent kernels support it.
   5.199 -
   5.200 -III. Driver operation
   5.201 -
   5.202 -IIIA. General
   5.203 -The Speedo3 is very similar to other Intel network chips, that is to say
   5.204 -"apparently designed on a different planet".  This chips retains the complex
   5.205 -Rx and Tx descriptors and multiple buffers pointers as previous chips, but
   5.206 -also has simplified Tx and Rx buffer modes.  This driver uses the "flexible"
   5.207 -Tx mode, but in a simplified lower-overhead manner: it associates only a
   5.208 -single buffer descriptor with each frame descriptor.
   5.209 -
   5.210 -Despite the extra space overhead in each receive skbuff, the driver must use
   5.211 -the simplified Rx buffer mode to assure that only a single data buffer is
   5.212 -associated with each RxFD. The driver implements this by reserving space
   5.213 -for the Rx descriptor at the head of each Rx skbuff.
   5.214 -
   5.215 -The Speedo-3 has receive and command unit base addresses that are added to
   5.216 -almost all descriptor pointers.  The driver sets these to zero, so that all
   5.217 -pointer fields are absolute addresses.
   5.218 -
   5.219 -The System Control Block (SCB) of some previous Intel chips exists on the
   5.220 -chip in both PCI I/O and memory space.  This driver uses the I/O space
   5.221 -registers, but might switch to memory mapped mode to better support non-x86
   5.222 -processors.
   5.223 -
   5.224 -IIIB. Transmit structure
   5.225 -
   5.226 -The driver must use the complex Tx command+descriptor mode in order to
   5.227 -have a indirect pointer to the skbuff data section.  Each Tx command block
   5.228 -(TxCB) is associated with two immediately appended Tx Buffer Descriptor
   5.229 -(TxBD).  A fixed ring of these TxCB+TxBD pairs are kept as part of the
   5.230 -speedo_private data structure for each adapter instance.
   5.231 -
   5.232 -The newer i82558 explicitly supports this structure, and can read the two
   5.233 -TxBDs in the same PCI burst as the TxCB.
   5.234 -
   5.235 -This ring structure is used for all normal transmit packets, but the
   5.236 -transmit packet descriptors aren't long enough for most non-Tx commands such
   5.237 -as CmdConfigure.  This is complicated by the possibility that the chip has
   5.238 -already loaded the link address in the previous descriptor.  So for these
   5.239 -commands we convert the next free descriptor on the ring to a NoOp, and point
   5.240 -that descriptor's link to the complex command.
   5.241 -
   5.242 -An additional complexity of these non-transmit commands are that they may be
   5.243 -added asynchronous to the normal transmit queue, so we disable interrupts
   5.244 -whenever the Tx descriptor ring is manipulated.
   5.245 -
   5.246 -A notable aspect of these special configure commands is that they do
   5.247 -work with the normal Tx ring entry scavenge method.  The Tx ring scavenge
   5.248 -is done at interrupt time using the 'dirty_tx' index, and checking for the
   5.249 -command-complete bit.  While the setup frames may have the NoOp command on the
   5.250 -Tx ring marked as complete, but not have completed the setup command, this
   5.251 -is not a problem.  The tx_ring entry can be still safely reused, as the
   5.252 -tx_skbuff[] entry is always empty for config_cmd and mc_setup frames.
   5.253 -
   5.254 -Commands may have bits set e.g. CmdSuspend in the command word to either
   5.255 -suspend or stop the transmit/command unit.  This driver always flags the last
   5.256 -command with CmdSuspend, erases the CmdSuspend in the previous command, and
   5.257 -then issues a CU_RESUME.
   5.258 -Note: Watch out for the potential race condition here: imagine
   5.259 -	erasing the previous suspend
   5.260 -		the chip processes the previous command
   5.261 -		the chip processes the final command, and suspends
   5.262 -	doing the CU_RESUME
   5.263 -		the chip processes the next-yet-valid post-final-command.
   5.264 -So blindly sending a CU_RESUME is only safe if we do it immediately after
   5.265 -after erasing the previous CmdSuspend, without the possibility of an
   5.266 -intervening delay.  Thus the resume command is always within the
   5.267 -interrupts-disabled region.  This is a timing dependence, but handling this
   5.268 -condition in a timing-independent way would considerably complicate the code.
   5.269 -
   5.270 -Note: In previous generation Intel chips, restarting the command unit was a
   5.271 -notoriously slow process.  This is presumably no longer true.
   5.272 -
   5.273 -IIIC. Receive structure
   5.274 -
   5.275 -Because of the bus-master support on the Speedo3 this driver uses the new
   5.276 -SKBUFF_RX_COPYBREAK scheme, rather than a fixed intermediate receive buffer.
   5.277 -This scheme allocates full-sized skbuffs as receive buffers.  The value
   5.278 -SKBUFF_RX_COPYBREAK is used as the copying breakpoint: it is chosen to
   5.279 -trade-off the memory wasted by passing the full-sized skbuff to the queue
   5.280 -layer for all frames vs. the copying cost of copying a frame to a
   5.281 -correctly-sized skbuff.
   5.282 -
   5.283 -For small frames the copying cost is negligible (esp. considering that we
   5.284 -are pre-loading the cache with immediately useful header information), so we
   5.285 -allocate a new, minimally-sized skbuff.  For large frames the copying cost
   5.286 -is non-trivial, and the larger copy might flush the cache of useful data, so
   5.287 -we pass up the skbuff the packet was received into.
   5.288 -
   5.289 -IV. Notes
   5.290 -
   5.291 -Thanks to Steve Williams of Intel for arranging the non-disclosure agreement
   5.292 -that stated that I could disclose the information.  But I still resent
   5.293 -having to sign an Intel NDA when I'm helping Intel sell their own product!
   5.294 -
   5.295 -*/
   5.296 -
   5.297 -static int speedo_found1(struct pci_dev *pdev, long ioaddr, int fnd_cnt, int acpi_idle_state);
   5.298 -
   5.299 -enum pci_flags_bit {
   5.300 -	PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
   5.301 -	PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
   5.302 -};
   5.303 -
   5.304 -static inline unsigned int io_inw(unsigned long port)
   5.305 -{
   5.306 -	return inw(port);
   5.307 -}
   5.308 -static inline void io_outw(unsigned int val, unsigned long port)
   5.309 -{
   5.310 -	outw(val, port);
   5.311 -}
   5.312 -
   5.313 -#ifndef USE_IO
   5.314 -/* Currently alpha headers define in/out macros.
   5.315 -   Undefine them.  2000/03/30  SAW */
   5.316 -#undef inb
   5.317 -#undef inw
   5.318 -#undef inl
   5.319 -#undef outb
   5.320 -#undef outw
   5.321 -#undef outl
   5.322 -#define inb readb
   5.323 -#define inw readw
   5.324 -#define inl readl
   5.325 -#define outb writeb
   5.326 -#define outw writew
   5.327 -#define outl writel
   5.328 -#endif
   5.329 -
   5.330 -/* How to wait for the command unit to accept a command.
   5.331 -   Typically this takes 0 ticks. */
   5.332 -static inline void wait_for_cmd_done(long cmd_ioaddr)
   5.333 -{
   5.334 -	int wait = 1000;
   5.335 -	do  udelay(1) ;
   5.336 -	while(inb(cmd_ioaddr) && --wait >= 0);
   5.337 -#ifndef final_version
   5.338 -	if (wait < 0)
   5.339 -		printk(KERN_ALERT "eepro100: wait_for_cmd_done timeout!\n");
   5.340 -#endif
   5.341 -}
   5.342 -
   5.343 -/* Offsets to the various registers.
   5.344 -   All accesses need not be longword aligned. */
   5.345 -enum speedo_offsets {
   5.346 -	SCBStatus = 0, SCBCmd = 2,	/* Rx/Command Unit command and status. */
   5.347 -	SCBPointer = 4,				/* General purpose pointer. */
   5.348 -	SCBPort = 8,				/* Misc. commands and operands.  */
   5.349 -	SCBflash = 12, SCBeeprom = 14, /* EEPROM and flash memory control. */
   5.350 -	SCBCtrlMDI = 16,			/* MDI interface control. */
   5.351 -	SCBEarlyRx = 20,			/* Early receive byte count. */
   5.352 -};
   5.353 -/* Commands that can be put in a command list entry. */
   5.354 -enum commands {
   5.355 -	CmdNOp = 0, CmdIASetup = 0x10000, CmdConfigure = 0x20000,
   5.356 -	CmdMulticastList = 0x30000, CmdTx = 0x40000, CmdTDR = 0x50000,
   5.357 -	CmdDump = 0x60000, CmdDiagnose = 0x70000,
   5.358 -	CmdSuspend = 0x40000000,	/* Suspend after completion. */
   5.359 -	CmdIntr = 0x20000000,		/* Interrupt after completion. */
   5.360 -	CmdTxFlex = 0x00080000,		/* Use "Flexible mode" for CmdTx command. */
   5.361 -};
   5.362 -/* Clear CmdSuspend (1<<30) avoiding interference with the card access to the
   5.363 -   status bits.  Previous driver versions used separate 16 bit fields for
   5.364 -   commands and statuses.  --SAW
   5.365 - */
   5.366 -#if defined(__alpha__)
   5.367 -# define clear_suspend(cmd)  clear_bit(30, &(cmd)->cmd_status);
   5.368 -#else
   5.369 -# if defined(__LITTLE_ENDIAN)
   5.370 -#  define clear_suspend(cmd)  ((__u16 *)&(cmd)->cmd_status)[1] &= ~0x4000
   5.371 -# elif defined(__BIG_ENDIAN)
   5.372 -#  define clear_suspend(cmd)  ((__u16 *)&(cmd)->cmd_status)[1] &= ~0x0040
   5.373 -# else
   5.374 -#  error Unsupported byteorder
   5.375 -# endif
   5.376 -#endif
   5.377 -
   5.378 -enum SCBCmdBits {
   5.379 -	SCBMaskCmdDone=0x8000, SCBMaskRxDone=0x4000, SCBMaskCmdIdle=0x2000,
   5.380 -	SCBMaskRxSuspend=0x1000, SCBMaskEarlyRx=0x0800, SCBMaskFlowCtl=0x0400,
   5.381 -	SCBTriggerIntr=0x0200, SCBMaskAll=0x0100,
   5.382 -	/* The rest are Rx and Tx commands. */
   5.383 -	CUStart=0x0010, CUResume=0x0020, CUStatsAddr=0x0040, CUShowStats=0x0050,
   5.384 -	CUCmdBase=0x0060,	/* CU Base address (set to zero) . */
   5.385 -	CUDumpStats=0x0070, /* Dump then reset stats counters. */
   5.386 -	RxStart=0x0001, RxResume=0x0002, RxAbort=0x0004, RxAddrLoad=0x0006,
   5.387 -	RxResumeNoResources=0x0007,
   5.388 -};
   5.389 -
   5.390 -enum SCBPort_cmds {
   5.391 -	PortReset=0, PortSelfTest=1, PortPartialReset=2, PortDump=3,
   5.392 -};
   5.393 -
   5.394 -/* The Speedo3 Rx and Tx frame/buffer descriptors. */
   5.395 -struct descriptor {			    /* A generic descriptor. */
   5.396 -	s32 cmd_status;				/* All command and status fields. */
   5.397 -	u32 link;				    /* struct descriptor *  */
   5.398 -	unsigned char params[0];
   5.399 -};
   5.400 -
   5.401 -/* The Speedo3 Rx and Tx buffer descriptors. */
   5.402 -struct RxFD {					/* Receive frame descriptor. */
   5.403 -	s32 status;
   5.404 -	u32 link;					/* struct RxFD * */
   5.405 -	u32 rx_buf_addr;			/* void * */
   5.406 -	u32 count;
   5.407 -};
   5.408 -
   5.409 -/* Selected elements of the Tx/RxFD.status word. */
   5.410 -enum RxFD_bits {
   5.411 -	RxComplete=0x8000, RxOK=0x2000,
   5.412 -	RxErrCRC=0x0800, RxErrAlign=0x0400, RxErrTooBig=0x0200, RxErrSymbol=0x0010,
   5.413 -	RxEth2Type=0x0020, RxNoMatch=0x0004, RxNoIAMatch=0x0002,
   5.414 -	TxUnderrun=0x1000,  StatusComplete=0x8000,
   5.415 -};
   5.416 -
   5.417 -#define CONFIG_DATA_SIZE 22
   5.418 -struct TxFD {					/* Transmit frame descriptor set. */
   5.419 -	s32 status;
   5.420 -	u32 link;					/* void * */
   5.421 -	u32 tx_desc_addr;			/* Always points to the tx_buf_addr element. */
   5.422 -	s32 count;					/* # of TBD (=1), Tx start thresh., etc. */
   5.423 -	/* This constitutes two "TBD" entries -- we only use one. */
   5.424 -#define TX_DESCR_BUF_OFFSET 16
   5.425 -	u32 tx_buf_addr0;			/* void *, frame to be transmitted.  */
   5.426 -	s32 tx_buf_size0;			/* Length of Tx frame. */
   5.427 -	u32 tx_buf_addr1;			/* void *, frame to be transmitted.  */
   5.428 -	s32 tx_buf_size1;			/* Length of Tx frame. */
   5.429 -	/* the structure must have space for at least CONFIG_DATA_SIZE starting
   5.430 -	 * from tx_desc_addr field */
   5.431 -};
   5.432 -
   5.433 -/* Multicast filter setting block.  --SAW */
   5.434 -struct speedo_mc_block {
   5.435 -	struct speedo_mc_block *next;
   5.436 -	unsigned int tx;
   5.437 -	dma_addr_t frame_dma;
   5.438 -	unsigned int len;
   5.439 -	struct descriptor frame __attribute__ ((__aligned__(16)));
   5.440 -};
   5.441 -
   5.442 -/* Elements of the dump_statistics block. This block must be lword aligned. */
   5.443 -struct speedo_stats {
   5.444 -	u32 tx_good_frames;
   5.445 -	u32 tx_coll16_errs;
   5.446 -	u32 tx_late_colls;
   5.447 -	u32 tx_underruns;
   5.448 -	u32 tx_lost_carrier;
   5.449 -	u32 tx_deferred;
   5.450 -	u32 tx_one_colls;
   5.451 -	u32 tx_multi_colls;
   5.452 -	u32 tx_total_colls;
   5.453 -	u32 rx_good_frames;
   5.454 -	u32 rx_crc_errs;
   5.455 -	u32 rx_align_errs;
   5.456 -	u32 rx_resource_errs;
   5.457 -	u32 rx_overrun_errs;
   5.458 -	u32 rx_colls_errs;
   5.459 -	u32 rx_runt_errs;
   5.460 -	u32 done_marker;
   5.461 -};
   5.462 -
   5.463 -enum Rx_ring_state_bits {
   5.464 -	RrNoMem=1, RrPostponed=2, RrNoResources=4, RrOOMReported=8,
   5.465 -};
   5.466 -
   5.467 -/* Do not change the position (alignment) of the first few elements!
   5.468 -   The later elements are grouped for cache locality.
   5.469 -
   5.470 -   Unfortunately, all the positions have been shifted since there.
   5.471 -   A new re-alignment is required.  2000/03/06  SAW */
   5.472 -struct speedo_private {
   5.473 -	struct TxFD	*tx_ring;				/* Commands (usually CmdTxPacket). */
   5.474 -	struct RxFD *rx_ringp[RX_RING_SIZE];/* Rx descriptor, used as ring. */
   5.475 -	/* The addresses of a Tx/Rx-in-place packets/buffers. */
   5.476 -	struct sk_buff *tx_skbuff[TX_RING_SIZE];
   5.477 -	struct sk_buff *rx_skbuff[RX_RING_SIZE];
   5.478 -	/* Mapped addresses of the rings. */
   5.479 -	dma_addr_t tx_ring_dma;
   5.480 -#define TX_RING_ELEM_DMA(sp, n) ((sp)->tx_ring_dma + (n)*sizeof(struct TxFD))
   5.481 -	dma_addr_t rx_ring_dma[RX_RING_SIZE];
   5.482 -	struct descriptor *last_cmd;		/* Last command sent. */
   5.483 -	unsigned int cur_tx, dirty_tx;		/* The ring entries to be free()ed. */
   5.484 -	spinlock_t lock;					/* Group with Tx control cache line. */
   5.485 -	u32 tx_threshold;					/* The value for txdesc.count. */
   5.486 -	struct RxFD *last_rxf;				/* Last filled RX buffer. */
   5.487 -	dma_addr_t last_rxf_dma;
   5.488 -	unsigned int cur_rx, dirty_rx;		/* The next free ring entry */
   5.489 -	long last_rx_time;			/* Last Rx, in jiffies, to handle Rx hang. */
   5.490 -	struct net_device_stats stats;
   5.491 -	struct speedo_stats *lstats;
   5.492 -	dma_addr_t lstats_dma;
   5.493 -	int chip_id;
   5.494 -	struct pci_dev *pdev;
   5.495 -	struct timer_list timer;			/* Media selection timer. */
   5.496 -	struct speedo_mc_block *mc_setup_head;/* Multicast setup frame list head. */
   5.497 -	struct speedo_mc_block *mc_setup_tail;/* Multicast setup frame list tail. */
   5.498 -	long in_interrupt;					/* Word-aligned dev->interrupt */
   5.499 -	unsigned char acpi_pwr;
   5.500 -	signed char rx_mode;					/* Current PROMISC/ALLMULTI setting. */
   5.501 -	unsigned int tx_full:1;				/* The Tx queue is full. */
   5.502 -	unsigned int full_duplex:1;			/* Full-duplex operation requested. */
   5.503 -	unsigned int flow_ctrl:1;			/* Use 802.3x flow control. */
   5.504 -	unsigned int rx_bug:1;				/* Work around receiver hang errata. */
   5.505 -	unsigned char default_port:8;		/* Last dev->if_port value. */
   5.506 -	unsigned char rx_ring_state;		/* RX ring status flags. */
   5.507 -	unsigned short phy[2];				/* PHY media interfaces available. */
   5.508 -	unsigned short advertising;			/* Current PHY advertised caps. */
   5.509 -	unsigned short partner;				/* Link partner caps. */
   5.510 -#ifdef CONFIG_PM
   5.511 -	u32 pm_state[16];
   5.512 -#endif
   5.513 -};
   5.514 -
   5.515 -/* The parameters for a CmdConfigure operation.
   5.516 -   There are so many options that it would be difficult to document each bit.
   5.517 -   We mostly use the default or recommended settings. */
   5.518 -static const char i82557_config_cmd[CONFIG_DATA_SIZE] = {
   5.519 -	22, 0x08, 0, 0,  0, 0, 0x32, 0x03,  1, /* 1=Use MII  0=Use AUI */
   5.520 -	0, 0x2E, 0,  0x60, 0,
   5.521 -	0xf2, 0x48,   0, 0x40, 0xf2, 0x80, 		/* 0x40=Force full-duplex */
   5.522 -	0x3f, 0x05, };
   5.523 -static const char i82558_config_cmd[CONFIG_DATA_SIZE] = {
   5.524 -	22, 0x08, 0, 1,  0, 0, 0x22, 0x03,  1, /* 1=Use MII  0=Use AUI */
   5.525 -	0, 0x2E, 0,  0x60, 0x08, 0x88,
   5.526 -	0x68, 0, 0x40, 0xf2, 0x84,		/* Disable FC */
   5.527 -	0x31, 0x05, };
   5.528 -
   5.529 -/* PHY media interface chips. */
   5.530 -static const char *phys[] = {
   5.531 -	"None", "i82553-A/B", "i82553-C", "i82503",
   5.532 -	"DP83840", "80c240", "80c24", "i82555",
   5.533 -	"unknown-8", "unknown-9", "DP83840A", "unknown-11",
   5.534 -	"unknown-12", "unknown-13", "unknown-14", "unknown-15", };
   5.535 -enum phy_chips { NonSuchPhy=0, I82553AB, I82553C, I82503, DP83840, S80C240,
   5.536 -					 S80C24, I82555, DP83840A=10, };
   5.537 -static const char is_mii[] = { 0, 1, 1, 0, 1, 1, 0, 1 };
   5.538 -#define EE_READ_CMD		(6)
   5.539 -
   5.540 -static int eepro100_init_one(struct pci_dev *pdev,
   5.541 -		const struct pci_device_id *ent);
   5.542 -static void eepro100_remove_one (struct pci_dev *pdev);
   5.543 -#ifdef CONFIG_PM
   5.544 -static int eepro100_suspend (struct pci_dev *pdev, u32 state);
   5.545 -static int eepro100_resume (struct pci_dev *pdev);
   5.546 -#endif
   5.547 -
   5.548 -static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len);
   5.549 -static int mdio_read(long ioaddr, int phy_id, int location);
   5.550 -static int mdio_write(long ioaddr, int phy_id, int location, int value);
   5.551 -static int speedo_open(struct net_device *dev);
   5.552 -static void speedo_resume(struct net_device *dev);
   5.553 -static void speedo_timer(unsigned long data);
   5.554 -static void speedo_init_rx_ring(struct net_device *dev);
   5.555 -static void speedo_tx_timeout(struct net_device *dev);
   5.556 -static int speedo_start_xmit(struct sk_buff *skb, struct net_device *dev);
   5.557 -static void speedo_refill_rx_buffers(struct net_device *dev, int force);
   5.558 -static int speedo_rx(struct net_device *dev);
   5.559 -static void speedo_tx_buffer_gc(struct net_device *dev);
   5.560 -static void speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
   5.561 -static int speedo_close(struct net_device *dev);
   5.562 -static struct net_device_stats *speedo_get_stats(struct net_device *dev);
   5.563 -static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
   5.564 -static void set_rx_mode(struct net_device *dev);
   5.565 -static void speedo_show_state(struct net_device *dev);
   5.566 -
   5.567 -
   5.568 -
   5.569 -#ifdef honor_default_port
   5.570 -/* Optional driver feature to allow forcing the transceiver setting.
   5.571 -   Not recommended. */
   5.572 -static int mii_ctrl[8] = { 0x3300, 0x3100, 0x0000, 0x0100,
   5.573 -						   0x2000, 0x2100, 0x0400, 0x3100};
   5.574 -#endif
   5.575 -
   5.576 -static int __devinit eepro100_init_one (struct pci_dev *pdev,
   5.577 -		const struct pci_device_id *ent)
   5.578 -{
   5.579 -	unsigned long ioaddr;
   5.580 -	int irq;
   5.581 -	int acpi_idle_state = 0, pm;
   5.582 -	static int cards_found /* = 0 */;
   5.583 -
   5.584 -	static int did_version /* = 0 */;		/* Already printed version info. */
   5.585 -	if (speedo_debug > 0  &&  did_version++ == 0)
   5.586 -		printk(version);
   5.587 -
   5.588 -	if (!request_region(pci_resource_start(pdev, 1),
   5.589 -			pci_resource_len(pdev, 1), "eepro100")) {
   5.590 -		printk (KERN_ERR "eepro100: cannot reserve I/O ports\n");
   5.591 -		goto err_out_none;
   5.592 -	}
   5.593 -	if (!request_mem_region(pci_resource_start(pdev, 0),
   5.594 -			pci_resource_len(pdev, 0), "eepro100")) {
   5.595 -		printk (KERN_ERR "eepro100: cannot reserve MMIO region\n");
   5.596 -		goto err_out_free_pio_region;
   5.597 -	}
   5.598 -
   5.599 -	irq = pdev->irq;
   5.600 -#ifdef USE_IO
   5.601 -	ioaddr = pci_resource_start(pdev, 1);
   5.602 -	if (speedo_debug > 2)
   5.603 -		printk("Found Intel i82557 PCI Speedo at I/O %#lx, IRQ %d.\n",
   5.604 -			   ioaddr, irq);
   5.605 -#else
   5.606 -	ioaddr = (unsigned long)ioremap(pci_resource_start(pdev, 0),
   5.607 -									pci_resource_len(pdev, 0));
   5.608 -	if (!ioaddr) {
   5.609 -		printk (KERN_ERR "eepro100: cannot remap MMIO region %lx @ %lx\n",
   5.610 -				pci_resource_len(pdev, 0), pci_resource_start(pdev, 0));
   5.611 -		goto err_out_free_mmio_region;
   5.612 -	}
   5.613 -	if (speedo_debug > 2)
   5.614 -		printk("Found Intel i82557 PCI Speedo, MMIO at %#lx, IRQ %d.\n",
   5.615 -			   pci_resource_start(pdev, 0), irq);
   5.616 -#endif
   5.617 -
   5.618 -	/* save power state b4 pci_enable_device overwrites it */
   5.619 -	pm = pci_find_capability(pdev, PCI_CAP_ID_PM);
   5.620 -	if (pm) {
   5.621 -		u16 pwr_command;
   5.622 -		pci_read_config_word(pdev, pm + PCI_PM_CTRL, &pwr_command);
   5.623 -		acpi_idle_state = pwr_command & PCI_PM_CTRL_STATE_MASK;
   5.624 -	}
   5.625 -
   5.626 -	if (pci_enable_device(pdev))
   5.627 -		goto err_out_free_mmio_region;
   5.628 -
   5.629 -	pci_set_master(pdev);
   5.630 -
   5.631 -	if (speedo_found1(pdev, ioaddr, cards_found, acpi_idle_state) == 0)
   5.632 -		cards_found++;
   5.633 -	else
   5.634 -		goto err_out_iounmap;
   5.635 -
   5.636 -	return 0;
   5.637 -
   5.638 -err_out_iounmap: ;
   5.639 -#ifndef USE_IO
   5.640 -	iounmap ((void *)ioaddr);
   5.641 -#endif
   5.642 -err_out_free_mmio_region:
   5.643 -	release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
   5.644 -err_out_free_pio_region:
   5.645 -	release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1));
   5.646 -err_out_none:
   5.647 -	return -ENODEV;
   5.648 -}
   5.649 -
   5.650 -static int speedo_found1(struct pci_dev *pdev,
   5.651 -		long ioaddr, int card_idx, int acpi_idle_state)
   5.652 -{
   5.653 -	struct net_device *dev;
   5.654 -	struct speedo_private *sp;
   5.655 -	const char *product;
   5.656 -	int i, option;
   5.657 -	u16 eeprom[0x100];
   5.658 -	int size;
   5.659 -	void *tx_ring_space;
   5.660 -	dma_addr_t tx_ring_dma;
   5.661 -
   5.662 -	size = TX_RING_SIZE * sizeof(struct TxFD) + sizeof(struct speedo_stats);
   5.663 -	tx_ring_space = pci_alloc_consistent(pdev, size, &tx_ring_dma);
   5.664 -	if (tx_ring_space == NULL)
   5.665 -		return -1;
   5.666 -
   5.667 -	dev = init_etherdev(NULL, sizeof(struct speedo_private));
   5.668 -	if (dev == NULL) {
   5.669 -		printk(KERN_ERR "eepro100: Could not allocate ethernet device.\n");
   5.670 -		pci_free_consistent(pdev, size, tx_ring_space, tx_ring_dma);
   5.671 -		return -1;
   5.672 -	}
   5.673 -
   5.674 -	if (dev->mem_start > 0)
   5.675 -		option = dev->mem_start;
   5.676 -	else if (card_idx >= 0  &&  options[card_idx] >= 0)
   5.677 -		option = options[card_idx];
   5.678 -	else
   5.679 -		option = 0;
   5.680 -
   5.681 -	/* Read the station address EEPROM before doing the reset.
   5.682 -	   Nominally his should even be done before accepting the device, but
   5.683 -	   then we wouldn't have a device name with which to report the error.
   5.684 -	   The size test is for 6 bit vs. 8 bit address serial EEPROMs.
   5.685 -	*/
   5.686 -	{
   5.687 -		unsigned long iobase;
   5.688 -		int read_cmd, ee_size;
   5.689 -		u16 sum;
   5.690 -		int j;
   5.691 -
   5.692 -		/* Use IO only to avoid postponed writes and satisfy EEPROM timing
   5.693 -		   requirements. */
   5.694 -		iobase = pci_resource_start(pdev, 1);
   5.695 -		if ((do_eeprom_cmd(iobase, EE_READ_CMD << 24, 27) & 0xffe0000)
   5.696 -			== 0xffe0000) {
   5.697 -			ee_size = 0x100;
   5.698 -			read_cmd = EE_READ_CMD << 24;
   5.699 -		} else {
   5.700 -			ee_size = 0x40;
   5.701 -			read_cmd = EE_READ_CMD << 22;
   5.702 -		}
   5.703 -
   5.704 -		for (j = 0, i = 0, sum = 0; i < ee_size; i++) {
   5.705 -			u16 value = do_eeprom_cmd(iobase, read_cmd | (i << 16), 27);
   5.706 -			eeprom[i] = value;
   5.707 -			sum += value;
   5.708 -			if (i < 3) {
   5.709 -				dev->dev_addr[j++] = value;
   5.710 -				dev->dev_addr[j++] = value >> 8;
   5.711 -			}
   5.712 -		}
   5.713 -		if (sum != 0xBABA)
   5.714 -			printk(KERN_WARNING "%s: Invalid EEPROM checksum %#4.4x, "
   5.715 -				   "check settings before activating this device!\n",
   5.716 -				   dev->name, sum);
   5.717 -		/* Don't  unregister_netdev(dev);  as the EEPro may actually be
   5.718 -		   usable, especially if the MAC address is set later.
   5.719 -		   On the other hand, it may be unusable if MDI data is corrupted. */
   5.720 -	}
   5.721 -
   5.722 -	/* Reset the chip: stop Tx and Rx processes and clear counters.
   5.723 -	   This takes less than 10usec and will easily finish before the next
   5.724 -	   action. */
   5.725 -	outl(PortReset, ioaddr + SCBPort);
   5.726 -	inl(ioaddr + SCBPort);
   5.727 -	udelay(10);
   5.728 -
   5.729 -	if (eeprom[3] & 0x0100)
   5.730 -		product = "OEM i82557/i82558 10/100 Ethernet";
   5.731 -	else
   5.732 -		product = pdev->name;
   5.733 -
   5.734 -	printk(KERN_INFO "%s: %s, ", dev->name, product);
   5.735 -
   5.736 -	for (i = 0; i < 5; i++)
   5.737 -		printk("%2.2X:", dev->dev_addr[i]);
   5.738 -	printk("%2.2X, ", dev->dev_addr[i]);
   5.739 -#ifdef USE_IO
   5.740 -	printk("I/O at %#3lx, ", ioaddr);
   5.741 -#endif
   5.742 -	printk("IRQ %d.\n", pdev->irq);
   5.743 -
   5.744 -#if 1 || defined(kernel_bloat)
   5.745 -	/* OK, this is pure kernel bloat.  I don't like it when other drivers
   5.746 -	   waste non-pageable kernel space to emit similar messages, but I need
   5.747 -	   them for bug reports. */
   5.748 -	{
   5.749 -		const char *connectors[] = {" RJ45", " BNC", " AUI", " MII"};
   5.750 -		/* The self-test results must be paragraph aligned. */
   5.751 -		volatile s32 *self_test_results;
   5.752 -		int boguscnt = 16000;	/* Timeout for set-test. */
   5.753 -		if ((eeprom[3] & 0x03) != 0x03)
   5.754 -			printk(KERN_INFO "  Receiver lock-up bug exists -- enabling"
   5.755 -				   " work-around.\n");
   5.756 -		printk(KERN_INFO "  Board assembly %4.4x%2.2x-%3.3d, Physical"
   5.757 -			   " connectors present:",
   5.758 -			   eeprom[8], eeprom[9]>>8, eeprom[9] & 0xff);
   5.759 -		for (i = 0; i < 4; i++)
   5.760 -			if (eeprom[5] & (1<<i))
   5.761 -				printk(connectors[i]);
   5.762 -		printk("\n"KERN_INFO"  Primary interface chip %s PHY #%d.\n",
   5.763 -			   phys[(eeprom[6]>>8)&15], eeprom[6] & 0x1f);
   5.764 -		if (eeprom[7] & 0x0700)
   5.765 -			printk(KERN_INFO "    Secondary interface chip %s.\n",
   5.766 -				   phys[(eeprom[7]>>8)&7]);
   5.767 -		if (((eeprom[6]>>8) & 0x3f) == DP83840
   5.768 -			||  ((eeprom[6]>>8) & 0x3f) == DP83840A) {
   5.769 -			int mdi_reg23 = mdio_read(ioaddr, eeprom[6] & 0x1f, 23) | 0x0422;
   5.770 -			if (congenb)
   5.771 -			  mdi_reg23 |= 0x0100;
   5.772 -			printk(KERN_INFO"  DP83840 specific setup, setting register 23 to %4.4x.\n",
   5.773 -				   mdi_reg23);
   5.774 -			mdio_write(ioaddr, eeprom[6] & 0x1f, 23, mdi_reg23);
   5.775 -		}
   5.776 -		if ((option >= 0) && (option & 0x70)) {
   5.777 -			printk(KERN_INFO "  Forcing %dMbs %s-duplex operation.\n",
   5.778 -				   (option & 0x20 ? 100 : 10),
   5.779 -				   (option & 0x10 ? "full" : "half"));
   5.780 -			mdio_write(ioaddr, eeprom[6] & 0x1f, 0,
   5.781 -					   ((option & 0x20) ? 0x2000 : 0) | 	/* 100mbps? */
   5.782 -					   ((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */
   5.783 -		}
   5.784 -
   5.785 -		/* Perform a system self-test. */
   5.786 -		self_test_results = (s32*) ((((long) tx_ring_space) + 15) & ~0xf);
   5.787 -		self_test_results[0] = 0;
   5.788 -		self_test_results[1] = -1;
   5.789 -		outl(tx_ring_dma | PortSelfTest, ioaddr + SCBPort);
   5.790 -		do {
   5.791 -			udelay(10);
   5.792 -		} while (self_test_results[1] == -1  &&  --boguscnt >= 0);
   5.793 -
   5.794 -		if (boguscnt < 0) {		/* Test optimized out. */
   5.795 -			printk(KERN_ERR "Self test failed, status %8.8x:\n"
   5.796 -				   KERN_ERR " Failure to initialize the i82557.\n"
   5.797 -				   KERN_ERR " Verify that the card is a bus-master"
   5.798 -				   " capable slot.\n",
   5.799 -				   self_test_results[1]);
   5.800 -		} else
   5.801 -			printk(KERN_INFO "  General self-test: %s.\n"
   5.802 -				   KERN_INFO "  Serial sub-system self-test: %s.\n"
   5.803 -				   KERN_INFO "  Internal registers self-test: %s.\n"
   5.804 -				   KERN_INFO "  ROM checksum self-test: %s (%#8.8x).\n",
   5.805 -				   self_test_results[1] & 0x1000 ? "failed" : "passed",
   5.806 -				   self_test_results[1] & 0x0020 ? "failed" : "passed",
   5.807 -				   self_test_results[1] & 0x0008 ? "failed" : "passed",
   5.808 -				   self_test_results[1] & 0x0004 ? "failed" : "passed",
   5.809 -				   self_test_results[0]);
   5.810 -	}
   5.811 -#endif  /* kernel_bloat */
   5.812 -
   5.813 -	outl(PortReset, ioaddr + SCBPort);
   5.814 -	inl(ioaddr + SCBPort);
   5.815 -	udelay(10);
   5.816 -
   5.817 -	/* Return the chip to its original power state. */
   5.818 -	SET_POWER_STATE(pdev, acpi_idle_state);
   5.819 -
   5.820 -	pci_set_drvdata (pdev, dev);
   5.821 -
   5.822 -	dev->base_addr = ioaddr;
   5.823 -	dev->irq = pdev->irq;
   5.824 -
   5.825 -	sp = dev->priv;
   5.826 -	sp->pdev = pdev;
   5.827 -	sp->acpi_pwr = acpi_idle_state;
   5.828 -	sp->tx_ring = tx_ring_space;
   5.829 -	sp->tx_ring_dma = tx_ring_dma;
   5.830 -	sp->lstats = (struct speedo_stats *)(sp->tx_ring + TX_RING_SIZE);
   5.831 -	sp->lstats_dma = TX_RING_ELEM_DMA(sp, TX_RING_SIZE);
   5.832 -	init_timer(&sp->timer); /* used in ioctl() */
   5.833 -
   5.834 -	sp->full_duplex = option >= 0 && (option & 0x10) ? 1 : 0;
   5.835 -	if (card_idx >= 0) {
   5.836 -		if (full_duplex[card_idx] >= 0)
   5.837 -			sp->full_duplex = full_duplex[card_idx];
   5.838 -	}
   5.839 -	sp->default_port = option >= 0 ? (option & 0x0f) : 0;
   5.840 -
   5.841 -	sp->phy[0] = eeprom[6];
   5.842 -	sp->phy[1] = eeprom[7];
   5.843 -	sp->rx_bug = (eeprom[3] & 0x03) == 3 ? 0 : 1;
   5.844 -
   5.845 -	if (sp->rx_bug)
   5.846 -		printk(KERN_INFO "  Receiver lock-up workaround activated.\n");
   5.847 -
   5.848 -	/* The Speedo-specific entries in the device structure. */
   5.849 -	dev->open = &speedo_open;
   5.850 -	dev->hard_start_xmit = &speedo_start_xmit;
   5.851 -	netif_set_tx_timeout(dev, &speedo_tx_timeout, TX_TIMEOUT);
   5.852 -	dev->stop = &speedo_close;
   5.853 -	dev->get_stats = &speedo_get_stats;
   5.854 -	dev->set_multicast_list = &set_rx_mode;
   5.855 -	dev->do_ioctl = &speedo_ioctl;
   5.856 -
   5.857 -	return 0;
   5.858 -}
   5.859 -
   5.860 -/* Serial EEPROM section.
   5.861 -   A "bit" grungy, but we work our way through bit-by-bit :->. */
   5.862 -/*  EEPROM_Ctrl bits. */
   5.863 -#define EE_SHIFT_CLK	0x01	/* EEPROM shift clock. */
   5.864 -#define EE_CS			0x02	/* EEPROM chip select. */
   5.865 -#define EE_DATA_WRITE	0x04	/* EEPROM chip data in. */
   5.866 -#define EE_DATA_READ	0x08	/* EEPROM chip data out. */
   5.867 -#define EE_ENB			(0x4800 | EE_CS)
   5.868 -#define EE_WRITE_0		0x4802
   5.869 -#define EE_WRITE_1		0x4806
   5.870 -#define EE_OFFSET		SCBeeprom
   5.871 -
   5.872 -/* The fixes for the code were kindly provided by Dragan Stancevic
   5.873 -   <visitor@valinux.com> to strictly follow Intel specifications of EEPROM
   5.874 -   access timing.
   5.875 -   The publicly available sheet 64486302 (sec. 3.1) specifies 1us access
   5.876 -   interval for serial EEPROM.  However, it looks like that there is an
   5.877 -   additional requirement dictating larger udelay's in the code below.
   5.878 -   2000/05/24  SAW */
   5.879 -static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len)
   5.880 -{
   5.881 -	unsigned retval = 0;
   5.882 -	long ee_addr = ioaddr + SCBeeprom;
   5.883 -
   5.884 -	io_outw(EE_ENB, ee_addr); udelay(2);
   5.885 -	io_outw(EE_ENB | EE_SHIFT_CLK, ee_addr); udelay(2);
   5.886 -
   5.887 -	/* Shift the command bits out. */
   5.888 -	do {
   5.889 -		short dataval = (cmd & (1 << cmd_len)) ? EE_WRITE_1 : EE_WRITE_0;
   5.890 -		io_outw(dataval, ee_addr); udelay(2);
   5.891 -		io_outw(dataval | EE_SHIFT_CLK, ee_addr); udelay(2);
   5.892 -		retval = (retval << 1) | ((io_inw(ee_addr) & EE_DATA_READ) ? 1 : 0);
   5.893 -	} while (--cmd_len >= 0);
   5.894 -	io_outw(EE_ENB, ee_addr); udelay(2);
   5.895 -
   5.896 -	/* Terminate the EEPROM access. */
   5.897 -	io_outw(EE_ENB & ~EE_CS, ee_addr);
   5.898 -	return retval;
   5.899 -}
   5.900 -
   5.901 -static int mdio_read(long ioaddr, int phy_id, int location)
   5.902 -{
   5.903 -	int val, boguscnt = 64*10;		/* <64 usec. to complete, typ 27 ticks */
   5.904 -	outl(0x08000000 | (location<<16) | (phy_id<<21), ioaddr + SCBCtrlMDI);
   5.905 -	do {
   5.906 -		val = inl(ioaddr + SCBCtrlMDI);
   5.907 -		if (--boguscnt < 0) {
   5.908 -			printk(KERN_ERR " mdio_read() timed out with val = %8.8x.\n", val);
   5.909 -			break;
   5.910 -		}
   5.911 -	} while (! (val & 0x10000000));
   5.912 -	return val & 0xffff;
   5.913 -}
   5.914 -
   5.915 -static int mdio_write(long ioaddr, int phy_id, int location, int value)
   5.916 -{
   5.917 -	int val, boguscnt = 64*10;		/* <64 usec. to complete, typ 27 ticks */
   5.918 -	outl(0x04000000 | (location<<16) | (phy_id<<21) | value,
   5.919 -		 ioaddr + SCBCtrlMDI);
   5.920 -	do {
   5.921 -		val = inl(ioaddr + SCBCtrlMDI);
   5.922 -		if (--boguscnt < 0) {
   5.923 -			printk(KERN_ERR" mdio_write() timed out with val = %8.8x.\n", val);
   5.924 -			break;
   5.925 -		}
   5.926 -	} while (! (val & 0x10000000));
   5.927 -	return val & 0xffff;
   5.928 -}
   5.929 -
   5.930 -
   5.931 -static int
   5.932 -speedo_open(struct net_device *dev)
   5.933 -{
   5.934 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
   5.935 -	long ioaddr = dev->base_addr;
   5.936 -	int retval;
   5.937 -
   5.938 -	if (speedo_debug > 1)
   5.939 -		printk(KERN_DEBUG "%s: speedo_open() irq %d.\n", dev->name, dev->irq);
   5.940 -
   5.941 -	MOD_INC_USE_COUNT;
   5.942 -
   5.943 -	SET_POWER_STATE(sp->pdev, 0);
   5.944 -
   5.945 -	/* Set up the Tx queue early.. */
   5.946 -	sp->cur_tx = 0;
   5.947 -	sp->dirty_tx = 0;
   5.948 -	sp->last_cmd = 0;
   5.949 -	sp->tx_full = 0;
   5.950 -	spin_lock_init(&sp->lock);
   5.951 -	sp->in_interrupt = 0;
   5.952 -
   5.953 -	/* .. we can safely take handler calls during init. */
   5.954 -	retval = request_irq(dev->irq, &speedo_interrupt, SA_SHIRQ, dev->name, dev);
   5.955 -	if (retval) {
   5.956 -		MOD_DEC_USE_COUNT;
   5.957 -		return retval;
   5.958 -	}
   5.959 -
   5.960 -	dev->if_port = sp->default_port;
   5.961 -
   5.962 -#ifdef oh_no_you_dont_unless_you_honour_the_options_passed_in_to_us
   5.963 -	/* Retrigger negotiation to reset previous errors. */
   5.964 -	if ((sp->phy[0] & 0x8000) == 0) {
   5.965 -		int phy_addr = sp->phy[0] & 0x1f ;
   5.966 -		/* Use 0x3300 for restarting NWay, other values to force xcvr:
   5.967 -		   0x0000 10-HD
   5.968 -		   0x0100 10-FD
   5.969 -		   0x2000 100-HD
   5.970 -		   0x2100 100-FD
   5.971 -		*/
   5.972 -#ifdef honor_default_port
   5.973 -		mdio_write(ioaddr, phy_addr, 0, mii_ctrl[dev->default_port & 7]);
   5.974 -#else
   5.975 -		mdio_write(ioaddr, phy_addr, 0, 0x3300);
   5.976 -#endif
   5.977 -	}
   5.978 -#endif
   5.979 -
   5.980 -	speedo_init_rx_ring(dev);
   5.981 -
   5.982 -	/* Fire up the hardware. */
   5.983 -	outw(SCBMaskAll, ioaddr + SCBCmd);
   5.984 -	speedo_resume(dev);
   5.985 -
   5.986 -	netdevice_start(dev);
   5.987 -	netif_start_queue(dev);
   5.988 -
   5.989 -	/* Setup the chip and configure the multicast list. */
   5.990 -	sp->mc_setup_head = NULL;
   5.991 -	sp->mc_setup_tail = NULL;
   5.992 -	sp->flow_ctrl = sp->partner = 0;
   5.993 -	sp->rx_mode = -1;			/* Invalid -> always reset the mode. */
   5.994 -	set_rx_mode(dev);
   5.995 -	if ((sp->phy[0] & 0x8000) == 0)
   5.996 -		sp->advertising = mdio_read(ioaddr, sp->phy[0] & 0x1f, 4);
   5.997 -
   5.998 -	if (speedo_debug > 2) {
   5.999 -		printk(KERN_DEBUG "%s: Done speedo_open(), status %8.8x.\n",
  5.1000 -			   dev->name, inw(ioaddr + SCBStatus));
  5.1001 -	}
  5.1002 -
  5.1003 -	/* Set the timer.  The timer serves a dual purpose:
  5.1004 -	   1) to monitor the media interface (e.g. link beat) and perhaps switch
  5.1005 -	   to an alternate media type
  5.1006 -	   2) to monitor Rx activity, and restart the Rx process if the receiver
  5.1007 -	   hangs. */
  5.1008 -	sp->timer.expires = RUN_AT((24*HZ)/10); 			/* 2.4 sec. */
  5.1009 -	sp->timer.data = (unsigned long)dev;
  5.1010 -	sp->timer.function = &speedo_timer;					/* timer handler */
  5.1011 -	add_timer(&sp->timer);
  5.1012 -
  5.1013 -	/* No need to wait for the command unit to accept here. */
  5.1014 -	if ((sp->phy[0] & 0x8000) == 0)
  5.1015 -		mdio_read(ioaddr, sp->phy[0] & 0x1f, 0);
  5.1016 -
  5.1017 -	return 0;
  5.1018 -}
  5.1019 -
  5.1020 -/* Start the chip hardware after a full reset. */
  5.1021 -static void speedo_resume(struct net_device *dev)
  5.1022 -{
  5.1023 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1024 -	long ioaddr = dev->base_addr;
  5.1025 -
  5.1026 -	/* Start with a Tx threshold of 256 (0x..20.... 8 byte units). */
  5.1027 -	sp->tx_threshold = 0x01208000;
  5.1028 -
  5.1029 -	/* Set the segment registers to '0'. */
  5.1030 -	wait_for_cmd_done(ioaddr + SCBCmd);
  5.1031 -	outl(0, ioaddr + SCBPointer);
  5.1032 -	/* impose a delay to avoid a bug */
  5.1033 -	inl(ioaddr + SCBPointer);
  5.1034 -	udelay(10);
  5.1035 -	outb(RxAddrLoad, ioaddr + SCBCmd);
  5.1036 -	wait_for_cmd_done(ioaddr + SCBCmd);
  5.1037 -	outb(CUCmdBase, ioaddr + SCBCmd);
  5.1038 -
  5.1039 -	/* Load the statistics block and rx ring addresses. */
  5.1040 -	wait_for_cmd_done(ioaddr + SCBCmd);
  5.1041 -	outl(sp->lstats_dma, ioaddr + SCBPointer);
  5.1042 -	outb(CUStatsAddr, ioaddr + SCBCmd);
  5.1043 -	sp->lstats->done_marker = 0;
  5.1044 -
  5.1045 -	if (sp->rx_ringp[sp->cur_rx % RX_RING_SIZE] == NULL) {
  5.1046 -		if (speedo_debug > 2)
  5.1047 -			printk(KERN_DEBUG "%s: NULL cur_rx in speedo_resume().\n",
  5.1048 -					dev->name);
  5.1049 -	} else {
  5.1050 -		wait_for_cmd_done(ioaddr + SCBCmd);
  5.1051 -		outl(sp->rx_ring_dma[sp->cur_rx % RX_RING_SIZE],
  5.1052 -			 ioaddr + SCBPointer);
  5.1053 -		outb(RxStart, ioaddr + SCBCmd);
  5.1054 -	}
  5.1055 -
  5.1056 -	wait_for_cmd_done(ioaddr + SCBCmd);
  5.1057 -	outb(CUDumpStats, ioaddr + SCBCmd);
  5.1058 -	udelay(30);
  5.1059 -
  5.1060 -	/* Fill the first command with our physical address. */
  5.1061 -	{
  5.1062 -		struct descriptor *ias_cmd;
  5.1063 -
  5.1064 -		ias_cmd =
  5.1065 -			(struct descriptor *)&sp->tx_ring[sp->cur_tx++ % TX_RING_SIZE];
  5.1066 -		/* Avoid a bug(?!) here by marking the command already completed. */
  5.1067 -		ias_cmd->cmd_status = cpu_to_le32((CmdSuspend | CmdIASetup) | 0xa000);
  5.1068 -		ias_cmd->link =
  5.1069 -			cpu_to_le32(TX_RING_ELEM_DMA(sp, sp->cur_tx % TX_RING_SIZE));
  5.1070 -		memcpy(ias_cmd->params, dev->dev_addr, 6);
  5.1071 -		sp->last_cmd = ias_cmd;
  5.1072 -	}
  5.1073 -
  5.1074 -	/* Start the chip's Tx process and unmask interrupts. */
  5.1075 -	wait_for_cmd_done(ioaddr + SCBCmd);
  5.1076 -	outl(TX_RING_ELEM_DMA(sp, sp->dirty_tx % TX_RING_SIZE),
  5.1077 -		 ioaddr + SCBPointer);
  5.1078 -	/* We are not ACK-ing FCP and ER in the interrupt handler yet so they should
  5.1079 -	   remain masked --Dragan */
  5.1080 -	outw(CUStart | SCBMaskEarlyRx | SCBMaskFlowCtl, ioaddr + SCBCmd);
  5.1081 -}
  5.1082 -
  5.1083 -/* Media monitoring and control. */
  5.1084 -static void speedo_timer(unsigned long data)
  5.1085 -{
  5.1086 -	struct net_device *dev = (struct net_device *)data;
  5.1087 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1088 -	long ioaddr = dev->base_addr;
  5.1089 -	int phy_num = sp->phy[0] & 0x1f;
  5.1090 -
  5.1091 -	/* We have MII and lost link beat. */
  5.1092 -	if ((sp->phy[0] & 0x8000) == 0) {
  5.1093 -		int partner = mdio_read(ioaddr, phy_num, 5);
  5.1094 -		if (partner != sp->partner) {
  5.1095 -			int flow_ctrl = sp->advertising & partner & 0x0400 ? 1 : 0;
  5.1096 -			if (speedo_debug > 2) {
  5.1097 -				printk(KERN_DEBUG "%s: Link status change.\n", dev->name);
  5.1098 -				printk(KERN_DEBUG "%s: Old partner %x, new %x, adv %x.\n",
  5.1099 -					   dev->name, sp->partner, partner, sp->advertising);
  5.1100 -			}
  5.1101 -			sp->partner = partner;
  5.1102 -			if (flow_ctrl != sp->flow_ctrl) {
  5.1103 -				sp->flow_ctrl = flow_ctrl;
  5.1104 -				sp->rx_mode = -1;	/* Trigger a reload. */
  5.1105 -			}
  5.1106 -			/* Clear sticky bit. */
  5.1107 -			mdio_read(ioaddr, phy_num, 1);
  5.1108 -			/* If link beat has returned... */
  5.1109 -			if (mdio_read(ioaddr, phy_num, 1) & 0x0004)
  5.1110 -				dev->flags |= IFF_RUNNING;
  5.1111 -			else
  5.1112 -				dev->flags &= ~IFF_RUNNING;
  5.1113 -		}
  5.1114 -	}
  5.1115 -	if (speedo_debug > 3) {
  5.1116 -		printk(KERN_DEBUG "%s: Media control tick, status %4.4x.\n",
  5.1117 -			   dev->name, inw(ioaddr + SCBStatus));
  5.1118 -	}
  5.1119 -	if (sp->rx_mode < 0  ||
  5.1120 -		(sp->rx_bug  && jiffies - sp->last_rx_time > 2*HZ)) {
  5.1121 -		/* We haven't received a packet in a Long Time.  We might have been
  5.1122 -		   bitten by the receiver hang bug.  This can be cleared by sending
  5.1123 -		   a set multicast list command. */
  5.1124 -		if (speedo_debug > 3)
  5.1125 -			printk(KERN_DEBUG "%s: Sending a multicast list set command"
  5.1126 -				   " from a timer routine,"
  5.1127 -				   " m=%d, j=%ld, l=%ld.\n",
  5.1128 -				   dev->name, sp->rx_mode, jiffies, sp->last_rx_time);
  5.1129 -		set_rx_mode(dev);
  5.1130 -	}
  5.1131 -	/* We must continue to monitor the media. */
  5.1132 -	sp->timer.expires = RUN_AT(2*HZ); 			/* 2.0 sec. */
  5.1133 -	add_timer(&sp->timer);
  5.1134 -#if defined(timer_exit)
  5.1135 -	timer_exit(&sp->timer);
  5.1136 -#endif
  5.1137 -}
  5.1138 -
  5.1139 -static void speedo_show_state(struct net_device *dev)
  5.1140 -{
  5.1141 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1142 -	int i;
  5.1143 -
  5.1144 -	/* Print a few items for debugging. */
  5.1145 -	if (speedo_debug > 0) {
  5.1146 -		int i;
  5.1147 -		printk(KERN_DEBUG "%s: Tx ring dump,  Tx queue %u / %u:\n", dev->name,
  5.1148 -			   sp->cur_tx, sp->dirty_tx);
  5.1149 -		for (i = 0; i < TX_RING_SIZE; i++)
  5.1150 -			printk(KERN_DEBUG "%s:  %c%c%2d %8.8x.\n", dev->name,
  5.1151 -				   i == sp->dirty_tx % TX_RING_SIZE ? '*' : ' ',
  5.1152 -				   i == sp->cur_tx % TX_RING_SIZE ? '=' : ' ',
  5.1153 -				   i, sp->tx_ring[i].status);
  5.1154 -	}
  5.1155 -	printk(KERN_DEBUG "%s: Printing Rx ring"
  5.1156 -		   " (next to receive into %u, dirty index %u).\n",
  5.1157 -		   dev->name, sp->cur_rx, sp->dirty_rx);
  5.1158 -
  5.1159 -	for (i = 0; i < RX_RING_SIZE; i++)
  5.1160 -		printk(KERN_DEBUG "%s: %c%c%c%2d %8.8x.\n", dev->name,
  5.1161 -			   sp->rx_ringp[i] == sp->last_rxf ? 'l' : ' ',
  5.1162 -			   i == sp->dirty_rx % RX_RING_SIZE ? '*' : ' ',
  5.1163 -			   i == sp->cur_rx % RX_RING_SIZE ? '=' : ' ',
  5.1164 -			   i, (sp->rx_ringp[i] != NULL) ?
  5.1165 -					   (unsigned)sp->rx_ringp[i]->status : 0);
  5.1166 -
  5.1167 -#if 0
  5.1168 -	{
  5.1169 -		long ioaddr = dev->base_addr;
  5.1170 -		int phy_num = sp->phy[0] & 0x1f;
  5.1171 -		for (i = 0; i < 16; i++) {
  5.1172 -			/* FIXME: what does it mean?  --SAW */
  5.1173 -			if (i == 6) i = 21;
  5.1174 -			printk(KERN_DEBUG "%s:  PHY index %d register %d is %4.4x.\n",
  5.1175 -				   dev->name, phy_num, i, mdio_read(ioaddr, phy_num, i));
  5.1176 -		}
  5.1177 -	}
  5.1178 -#endif
  5.1179 -
  5.1180 -}
  5.1181 -
  5.1182 -/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
  5.1183 -static void
  5.1184 -speedo_init_rx_ring(struct net_device *dev)
  5.1185 -{
  5.1186 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1187 -	struct RxFD *rxf, *last_rxf = NULL;
  5.1188 -	dma_addr_t last_rxf_dma = 0 /* to shut up the compiler */;
  5.1189 -	int i;
  5.1190 -
  5.1191 -	sp->cur_rx = 0;
  5.1192 -
  5.1193 -	for (i = 0; i < RX_RING_SIZE; i++) {
  5.1194 -		struct sk_buff *skb;
  5.1195 -		skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD));
  5.1196 -		sp->rx_skbuff[i] = skb;
  5.1197 -		if (skb == NULL)
  5.1198 -			break;			/* OK.  Just initially short of Rx bufs. */
  5.1199 -		skb->dev = dev;			/* Mark as being used by this device. */
  5.1200 -		rxf = (struct RxFD *)skb->tail;
  5.1201 -		sp->rx_ringp[i] = rxf;
  5.1202 -		sp->rx_ring_dma[i] =
  5.1203 -			pci_map_single(sp->pdev, rxf,
  5.1204 -					PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_BIDIRECTIONAL);
  5.1205 -		skb_reserve(skb, sizeof(struct RxFD));
  5.1206 -		if (last_rxf) {
  5.1207 -			last_rxf->link = cpu_to_le32(sp->rx_ring_dma[i]);
  5.1208 -			pci_dma_sync_single(sp->pdev, last_rxf_dma,
  5.1209 -					sizeof(struct RxFD), PCI_DMA_TODEVICE);
  5.1210 -		}
  5.1211 -		last_rxf = rxf;
  5.1212 -		last_rxf_dma = sp->rx_ring_dma[i];
  5.1213 -		rxf->status = cpu_to_le32(0x00000001);	/* '1' is flag value only. */
  5.1214 -		rxf->link = 0;						/* None yet. */
  5.1215 -		/* This field unused by i82557. */
  5.1216 -		rxf->rx_buf_addr = 0xffffffff;
  5.1217 -		rxf->count = cpu_to_le32(PKT_BUF_SZ << 16);
  5.1218 -		pci_dma_sync_single(sp->pdev, sp->rx_ring_dma[i],
  5.1219 -				sizeof(struct RxFD), PCI_DMA_TODEVICE);
  5.1220 -	}
  5.1221 -	sp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
  5.1222 -	/* Mark the last entry as end-of-list. */
  5.1223 -	last_rxf->status = cpu_to_le32(0xC0000002);	/* '2' is flag value only. */
  5.1224 -	pci_dma_sync_single(sp->pdev, sp->rx_ring_dma[RX_RING_SIZE-1],
  5.1225 -			sizeof(struct RxFD), PCI_DMA_TODEVICE);
  5.1226 -	sp->last_rxf = last_rxf;
  5.1227 -	sp->last_rxf_dma = last_rxf_dma;
  5.1228 -}
  5.1229 -
  5.1230 -static void speedo_purge_tx(struct net_device *dev)
  5.1231 -{
  5.1232 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1233 -	int entry;
  5.1234 -
  5.1235 -	while ((int)(sp->cur_tx - sp->dirty_tx) > 0) {
  5.1236 -		entry = sp->dirty_tx % TX_RING_SIZE;
  5.1237 -		if (sp->tx_skbuff[entry]) {
  5.1238 -			sp->stats.tx_errors++;
  5.1239 -			pci_unmap_single(sp->pdev,
  5.1240 -					le32_to_cpu(sp->tx_ring[entry].tx_buf_addr0),
  5.1241 -					sp->tx_skbuff[entry]->len, PCI_DMA_TODEVICE);
  5.1242 -			dev_kfree_skb_irq(sp->tx_skbuff[entry]);
  5.1243 -			sp->tx_skbuff[entry] = 0;
  5.1244 -		}
  5.1245 -		sp->dirty_tx++;
  5.1246 -	}
  5.1247 -	while (sp->mc_setup_head != NULL) {
  5.1248 -		struct speedo_mc_block *t;
  5.1249 -		if (speedo_debug > 1)
  5.1250 -			printk(KERN_DEBUG "%s: freeing mc frame.\n", dev->name);
  5.1251 -		pci_unmap_single(sp->pdev, sp->mc_setup_head->frame_dma,
  5.1252 -				sp->mc_setup_head->len, PCI_DMA_TODEVICE);
  5.1253 -		t = sp->mc_setup_head->next;
  5.1254 -		kfree(sp->mc_setup_head);
  5.1255 -		sp->mc_setup_head = t;
  5.1256 -	}
  5.1257 -	sp->mc_setup_tail = NULL;
  5.1258 -	sp->tx_full = 0;
  5.1259 -	netif_wake_queue(dev);
  5.1260 -}
  5.1261 -
  5.1262 -static void reset_mii(struct net_device *dev)
  5.1263 -{
  5.1264 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1265 -	long ioaddr = dev->base_addr;
  5.1266 -	/* Reset the MII transceiver, suggested by Fred Young @ scalable.com. */
  5.1267 -	if ((sp->phy[0] & 0x8000) == 0) {
  5.1268 -		int phy_addr = sp->phy[0] & 0x1f;
  5.1269 -		int advertising = mdio_read(ioaddr, phy_addr, 4);
  5.1270 -		int mii_bmcr = mdio_read(ioaddr, phy_addr, 0);
  5.1271 -		mdio_write(ioaddr, phy_addr, 0, 0x0400);
  5.1272 -		mdio_write(ioaddr, phy_addr, 1, 0x0000);
  5.1273 -		mdio_write(ioaddr, phy_addr, 4, 0x0000);
  5.1274 -		mdio_write(ioaddr, phy_addr, 0, 0x8000);
  5.1275 -#ifdef honor_default_port
  5.1276 -		mdio_write(ioaddr, phy_addr, 0, mii_ctrl[dev->default_port & 7]);
  5.1277 -#else
  5.1278 -		mdio_read(ioaddr, phy_addr, 0);
  5.1279 -		mdio_write(ioaddr, phy_addr, 0, mii_bmcr);
  5.1280 -		mdio_write(ioaddr, phy_addr, 4, advertising);
  5.1281 -#endif
  5.1282 -	}
  5.1283 -}
  5.1284 -
  5.1285 -static void speedo_tx_timeout(struct net_device *dev)
  5.1286 -{
  5.1287 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1288 -	long ioaddr = dev->base_addr;
  5.1289 -	int status = inw(ioaddr + SCBStatus);
  5.1290 -	unsigned long flags;
  5.1291 -
  5.1292 -	printk(KERN_WARNING "%s: Transmit timed out: status %4.4x "
  5.1293 -		   " %4.4x at %d/%d command %8.8x.\n",
  5.1294 -		   dev->name, status, inw(ioaddr + SCBCmd),
  5.1295 -		   sp->dirty_tx, sp->cur_tx,
  5.1296 -		   sp->tx_ring[sp->dirty_tx % TX_RING_SIZE].status);
  5.1297 -
  5.1298 -	speedo_show_state(dev);
  5.1299 -#if 0
  5.1300 -	if ((status & 0x00C0) != 0x0080
  5.1301 -		&&  (status & 0x003C) == 0x0010) {
  5.1302 -		/* Only the command unit has stopped. */
  5.1303 -		printk(KERN_WARNING "%s: Trying to restart the transmitter...\n",
  5.1304 -			   dev->name);
  5.1305 -		outl(TX_RING_ELEM_DMA(sp, dirty_tx % TX_RING_SIZE]),
  5.1306 -			 ioaddr + SCBPointer);
  5.1307 -		outw(CUStart, ioaddr + SCBCmd);
  5.1308 -		reset_mii(dev);
  5.1309 -	} else {
  5.1310 -#else
  5.1311 -	{
  5.1312 -#endif
  5.1313 -		del_timer_sync(&sp->timer);
  5.1314 -		/* Reset the Tx and Rx units. */
  5.1315 -		outl(PortReset, ioaddr + SCBPort);
  5.1316 -		/* We may get spurious interrupts here.  But I don't think that they
  5.1317 -		   may do much harm.  1999/12/09 SAW */
  5.1318 -		udelay(10);
  5.1319 -		/* Disable interrupts. */
  5.1320 -		outw(SCBMaskAll, ioaddr + SCBCmd);
  5.1321 -		synchronize_irq();
  5.1322 -		speedo_tx_buffer_gc(dev);
  5.1323 -		/* Free as much as possible.
  5.1324 -		   It helps to recover from a hang because of out-of-memory.
  5.1325 -		   It also simplifies speedo_resume() in case TX ring is full or
  5.1326 -		   close-to-be full. */
  5.1327 -		speedo_purge_tx(dev);
  5.1328 -		speedo_refill_rx_buffers(dev, 1);
  5.1329 -		spin_lock_irqsave(&sp->lock, flags);
  5.1330 -		speedo_resume(dev);
  5.1331 -		sp->rx_mode = -1;
  5.1332 -		dev->trans_start = jiffies;
  5.1333 -		spin_unlock_irqrestore(&sp->lock, flags);
  5.1334 -		set_rx_mode(dev); /* it takes the spinlock itself --SAW */
  5.1335 -		/* Reset MII transceiver.  Do it before starting the timer to serialize
  5.1336 -		   mdio_xxx operations.  Yes, it's a paranoya :-)  2000/05/09 SAW */
  5.1337 -		reset_mii(dev);
  5.1338 -		sp->timer.expires = RUN_AT(2*HZ);
  5.1339 -		add_timer(&sp->timer);
  5.1340 -	}
  5.1341 -	return;
  5.1342 -}
  5.1343 -
  5.1344 -static int
  5.1345 -speedo_start_xmit(struct sk_buff *skb, struct net_device *dev)
  5.1346 -{
  5.1347 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1348 -	long ioaddr = dev->base_addr;
  5.1349 -	int entry;
  5.1350 -
  5.1351 -	/* Prevent interrupts from changing the Tx ring from underneath us. */
  5.1352 -	unsigned long flags;
  5.1353 -
  5.1354 -	spin_lock_irqsave(&sp->lock, flags);
  5.1355 -
  5.1356 -	/* Check if there are enough space. */
  5.1357 -	if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
  5.1358 -		printk(KERN_ERR "%s: incorrect tbusy state, fixed.\n", dev->name);
  5.1359 -		netif_stop_queue(dev);
  5.1360 -		sp->tx_full = 1;
  5.1361 -		spin_unlock_irqrestore(&sp->lock, flags);
  5.1362 -		return 1;
  5.1363 -	}
  5.1364 -
  5.1365 -	/* Calculate the Tx descriptor entry. */
  5.1366 -	entry = sp->cur_tx++ % TX_RING_SIZE;
  5.1367 -
  5.1368 -	sp->tx_skbuff[entry] = skb;
  5.1369 -	sp->tx_ring[entry].status =
  5.1370 -		cpu_to_le32(CmdSuspend | CmdTx | CmdTxFlex);
  5.1371 -	if (!(entry & ((TX_RING_SIZE>>2)-1)))
  5.1372 -		sp->tx_ring[entry].status |= cpu_to_le32(CmdIntr);
  5.1373 -	sp->tx_ring[entry].link =
  5.1374 -		cpu_to_le32(TX_RING_ELEM_DMA(sp, sp->cur_tx % TX_RING_SIZE));
  5.1375 -	sp->tx_ring[entry].tx_desc_addr =
  5.1376 -		cpu_to_le32(TX_RING_ELEM_DMA(sp, entry) + TX_DESCR_BUF_OFFSET);
  5.1377 -	/* The data region is always in one buffer descriptor. */
  5.1378 -	sp->tx_ring[entry].count = cpu_to_le32(sp->tx_threshold);
  5.1379 -	sp->tx_ring[entry].tx_buf_addr0 =
  5.1380 -		cpu_to_le32(pci_map_single(sp->pdev, skb->data,
  5.1381 -					   skb->len, PCI_DMA_TODEVICE));
  5.1382 -	sp->tx_ring[entry].tx_buf_size0 = cpu_to_le32(skb->len);
  5.1383 -
  5.1384 -	/* workaround for hardware bug on 10 mbit half duplex */
  5.1385 -
  5.1386 -	if ((sp->partner==0) && (sp->chip_id==1)) {
  5.1387 -		wait_for_cmd_done(ioaddr + SCBCmd);
  5.1388 -		outb(0 , ioaddr + SCBCmd);
  5.1389 -	}
  5.1390 -
  5.1391 -	/* Trigger the command unit resume. */
  5.1392 -	wait_for_cmd_done(ioaddr + SCBCmd);
  5.1393 -	clear_suspend(sp->last_cmd);
  5.1394 -	/* We want the time window between clearing suspend flag on the previous
  5.1395 -	   command and resuming CU to be as small as possible.
  5.1396 -	   Interrupts in between are very undesired.  --SAW */
  5.1397 -	outb(CUResume, ioaddr + SCBCmd);
  5.1398 -	sp->last_cmd = (struct descriptor *)&sp->tx_ring[entry];
  5.1399 -
  5.1400 -	/* Leave room for set_rx_mode(). If there is no more space than reserved
  5.1401 -	   for multicast filter mark the ring as full. */
  5.1402 -	if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
  5.1403 -		netif_stop_queue(dev);
  5.1404 -		sp->tx_full = 1;
  5.1405 -	}
  5.1406 -
  5.1407 -	spin_unlock_irqrestore(&sp->lock, flags);
  5.1408 -
  5.1409 -	dev->trans_start = jiffies;
  5.1410 -
  5.1411 -	return 0;
  5.1412 -}
  5.1413 -
  5.1414 -static void speedo_tx_buffer_gc(struct net_device *dev)
  5.1415 -{
  5.1416 -	unsigned int dirty_tx;
  5.1417 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1418 -
  5.1419 -	dirty_tx = sp->dirty_tx;
  5.1420 -	while ((int)(sp->cur_tx - dirty_tx) > 0) {
  5.1421 -		int entry = dirty_tx % TX_RING_SIZE;
  5.1422 -		int status = le32_to_cpu(sp->tx_ring[entry].status);
  5.1423 -
  5.1424 -		if (speedo_debug > 5)
  5.1425 -			printk(KERN_DEBUG " scavenge candidate %d status %4.4x.\n",
  5.1426 -				   entry, status);
  5.1427 -		if ((status & StatusComplete) == 0)
  5.1428 -			break;			/* It still hasn't been processed. */
  5.1429 -		if (status & TxUnderrun)
  5.1430 -			if (sp->tx_threshold < 0x01e08000) {
  5.1431 -				if (speedo_debug > 2)
  5.1432 -					printk(KERN_DEBUG "%s: TX underrun, threshold adjusted.\n",
  5.1433 -						   dev->name);
  5.1434 -				sp->tx_threshold += 0x00040000;
  5.1435 -			}
  5.1436 -		/* Free the original skb. */
  5.1437 -		if (sp->tx_skbuff[entry]) {
  5.1438 -			sp->stats.tx_packets++;	/* Count only user packets. */
  5.1439 -			sp->stats.tx_bytes += sp->tx_skbuff[entry]->len;
  5.1440 -			pci_unmap_single(sp->pdev,
  5.1441 -					le32_to_cpu(sp->tx_ring[entry].tx_buf_addr0),
  5.1442 -					sp->tx_skbuff[entry]->len, PCI_DMA_TODEVICE);
  5.1443 -			dev_kfree_skb_irq(sp->tx_skbuff[entry]);
  5.1444 -			sp->tx_skbuff[entry] = 0;
  5.1445 -		}
  5.1446 -		dirty_tx++;
  5.1447 -	}
  5.1448 -
  5.1449 -	if (speedo_debug && (int)(sp->cur_tx - dirty_tx) > TX_RING_SIZE) {
  5.1450 -		printk(KERN_ERR "out-of-sync dirty pointer, %d vs. %d,"
  5.1451 -			   " full=%d.\n",
  5.1452 -			   dirty_tx, sp->cur_tx, sp->tx_full);
  5.1453 -		dirty_tx += TX_RING_SIZE;
  5.1454 -	}
  5.1455 -
  5.1456 -	while (sp->mc_setup_head != NULL
  5.1457 -		   && (int)(dirty_tx - sp->mc_setup_head->tx - 1) > 0) {
  5.1458 -		struct speedo_mc_block *t;
  5.1459 -		if (speedo_debug > 1)
  5.1460 -			printk(KERN_DEBUG "%s: freeing mc frame.\n", dev->name);
  5.1461 -		pci_unmap_single(sp->pdev, sp->mc_setup_head->frame_dma,
  5.1462 -				sp->mc_setup_head->len, PCI_DMA_TODEVICE);
  5.1463 -		t = sp->mc_setup_head->next;
  5.1464 -		kfree(sp->mc_setup_head);
  5.1465 -		sp->mc_setup_head = t;
  5.1466 -	}
  5.1467 -	if (sp->mc_setup_head == NULL)
  5.1468 -		sp->mc_setup_tail = NULL;
  5.1469 -
  5.1470 -	sp->dirty_tx = dirty_tx;
  5.1471 -}
  5.1472 -
  5.1473 -/* The interrupt handler does all of the Rx thread work and cleans up
  5.1474 -   after the Tx thread. */
  5.1475 -static void speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
  5.1476 -{
  5.1477 -	struct net_device *dev = (struct net_device *)dev_instance;
  5.1478 -	struct speedo_private *sp;
  5.1479 -	long ioaddr, boguscnt = max_interrupt_work;
  5.1480 -	unsigned short status;
  5.1481 -
  5.1482 -#ifndef final_version
  5.1483 -	if (dev == NULL) {
  5.1484 -		printk(KERN_ERR "speedo_interrupt(): irq %d for unknown device.\n", irq);
  5.1485 -		return;
  5.1486 -	}
  5.1487 -#endif
  5.1488 -
  5.1489 -	ioaddr = dev->base_addr;
  5.1490 -	sp = (struct speedo_private *)dev->priv;
  5.1491 -
  5.1492 -#ifndef final_version
  5.1493 -	/* A lock to prevent simultaneous entry on SMP machines. */
  5.1494 -	if (test_and_set_bit(0, (void*)&sp->in_interrupt)) {
  5.1495 -		printk(KERN_ERR"%s: SMP simultaneous entry of an interrupt handler.\n",
  5.1496 -			   dev->name);
  5.1497 -		sp->in_interrupt = 0;	/* Avoid halting machine. */
  5.1498 -		return;
  5.1499 -	}
  5.1500 -#endif
  5.1501 -
  5.1502 -	do {
  5.1503 -		status = inw(ioaddr + SCBStatus);
  5.1504 -		/* Acknowledge all of the current interrupt sources ASAP. */
  5.1505 -		/* Will change from 0xfc00 to 0xff00 when we start handling
  5.1506 -		   FCP and ER interrupts --Dragan */
  5.1507 -		outw(status & 0xfc00, ioaddr + SCBStatus);
  5.1508 -
  5.1509 -		if (speedo_debug > 4)
  5.1510 -			printk(KERN_DEBUG "%s: interrupt  status=%#4.4x.\n",
  5.1511 -				   dev->name, status);
  5.1512 -
  5.1513 -		if ((status & 0xfc00) == 0)
  5.1514 -			break;
  5.1515 -
  5.1516 -		/* Always check if all rx buffers are allocated.  --SAW */
  5.1517 -		speedo_refill_rx_buffers(dev, 0);
  5.1518 -
  5.1519 -		if ((status & 0x5000) ||	/* Packet received, or Rx error. */
  5.1520 -			(sp->rx_ring_state&(RrNoMem|RrPostponed)) == RrPostponed)
  5.1521 -									/* Need to gather the postponed packet. */
  5.1522 -			speedo_rx(dev);
  5.1523 -
  5.1524 -		if (status & 0x1000) {
  5.1525 -			spin_lock(&sp->lock);
  5.1526 -			if ((status & 0x003c) == 0x0028) {		/* No more Rx buffers. */
  5.1527 -				struct RxFD *rxf;
  5.1528 -				printk(KERN_WARNING "%s: card reports no RX buffers.\n",
  5.1529 -						dev->name);
  5.1530 -				rxf = sp->rx_ringp[sp->cur_rx % RX_RING_SIZE];
  5.1531 -				if (rxf == NULL) {
  5.1532 -					if (speedo_debug > 2)
  5.1533 -						printk(KERN_DEBUG
  5.1534 -								"%s: NULL cur_rx in speedo_interrupt().\n",
  5.1535 -								dev->name);
  5.1536 -					sp->rx_ring_state |= RrNoMem|RrNoResources;
  5.1537 -				} else if (rxf == sp->last_rxf) {
  5.1538 -					if (speedo_debug > 2)
  5.1539 -						printk(KERN_DEBUG
  5.1540 -								"%s: cur_rx is last in speedo_interrupt().\n",
  5.1541 -								dev->name);
  5.1542 -					sp->rx_ring_state |= RrNoMem|RrNoResources;
  5.1543 -				} else
  5.1544 -					outb(RxResumeNoResources, ioaddr + SCBCmd);
  5.1545 -			} else if ((status & 0x003c) == 0x0008) { /* No resources. */
  5.1546 -				struct RxFD *rxf;
  5.1547 -				printk(KERN_WARNING "%s: card reports no resources.\n",
  5.1548 -						dev->name);
  5.1549 -				rxf = sp->rx_ringp[sp->cur_rx % RX_RING_SIZE];
  5.1550 -				if (rxf == NULL) {
  5.1551 -					if (speedo_debug > 2)
  5.1552 -						printk(KERN_DEBUG
  5.1553 -								"%s: NULL cur_rx in speedo_interrupt().\n",
  5.1554 -								dev->name);
  5.1555 -					sp->rx_ring_state |= RrNoMem|RrNoResources;
  5.1556 -				} else if (rxf == sp->last_rxf) {
  5.1557 -					if (speedo_debug > 2)
  5.1558 -						printk(KERN_DEBUG
  5.1559 -								"%s: cur_rx is last in speedo_interrupt().\n",
  5.1560 -								dev->name);
  5.1561 -					sp->rx_ring_state |= RrNoMem|RrNoResources;
  5.1562 -				} else {
  5.1563 -					/* Restart the receiver. */
  5.1564 -					outl(sp->rx_ring_dma[sp->cur_rx % RX_RING_SIZE],
  5.1565 -						 ioaddr + SCBPointer);
  5.1566 -					outb(RxStart, ioaddr + SCBCmd);
  5.1567 -				}
  5.1568 -			}
  5.1569 -			sp->stats.rx_errors++;
  5.1570 -			spin_unlock(&sp->lock);
  5.1571 -		}
  5.1572 -
  5.1573 -		if ((sp->rx_ring_state&(RrNoMem|RrNoResources)) == RrNoResources) {
  5.1574 -			printk(KERN_WARNING
  5.1575 -					"%s: restart the receiver after a possible hang.\n",
  5.1576 -					dev->name);
  5.1577 -			spin_lock(&sp->lock);
  5.1578 -			/* Restart the receiver.
  5.1579 -			   I'm not sure if it's always right to restart the receiver
  5.1580 -			   here but I don't know another way to prevent receiver hangs.
  5.1581 -			   1999/12/25 SAW */
  5.1582 -			outl(sp->rx_ring_dma[sp->cur_rx % RX_RING_SIZE],
  5.1583 -				 ioaddr + SCBPointer);
  5.1584 -			outb(RxStart, ioaddr + SCBCmd);
  5.1585 -			sp->rx_ring_state &= ~RrNoResources;
  5.1586 -			spin_unlock(&sp->lock);
  5.1587 -		}
  5.1588 -
  5.1589 -		/* User interrupt, Command/Tx unit interrupt or CU not active. */
  5.1590 -		if (status & 0xA400) {
  5.1591 -			spin_lock(&sp->lock);
  5.1592 -			speedo_tx_buffer_gc(dev);
  5.1593 -			if (sp->tx_full
  5.1594 -				&& (int)(sp->cur_tx - sp->dirty_tx) < TX_QUEUE_UNFULL) {
  5.1595 -				/* The ring is no longer full. */
  5.1596 -				sp->tx_full = 0;
  5.1597 -				netif_wake_queue(dev); /* Attention: under a spinlock.  --SAW */
  5.1598 -			}
  5.1599 -			spin_unlock(&sp->lock);
  5.1600 -		}
  5.1601 -
  5.1602 -		if (--boguscnt < 0) {
  5.1603 -			printk(KERN_ERR "%s: Too much work at interrupt, status=0x%4.4x.\n",
  5.1604 -				   dev->name, status);
  5.1605 -			/* Clear all interrupt sources. */
  5.1606 -			/* Will change from 0xfc00 to 0xff00 when we start handling
  5.1607 -			   FCP and ER interrupts --Dragan */
  5.1608 -			outw(0xfc00, ioaddr + SCBStatus);
  5.1609 -			break;
  5.1610 -		}
  5.1611 -	} while (1);
  5.1612 -
  5.1613 -	if (speedo_debug > 3)
  5.1614 -		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
  5.1615 -			   dev->name, inw(ioaddr + SCBStatus));
  5.1616 -
  5.1617 -	clear_bit(0, (void*)&sp->in_interrupt);
  5.1618 -	return;
  5.1619 -}
  5.1620 -
  5.1621 -static inline struct RxFD *speedo_rx_alloc(struct net_device *dev, int entry)
  5.1622 -{
  5.1623 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1624 -	struct RxFD *rxf;
  5.1625 -	struct sk_buff *skb;
  5.1626 -	/* Get a fresh skbuff to replace the consumed one. */
  5.1627 -	skb = dev_alloc_skb(PKT_BUF_SZ + sizeof(struct RxFD));
  5.1628 -	sp->rx_skbuff[entry] = skb;
  5.1629 -	if (skb == NULL) {
  5.1630 -		sp->rx_ringp[entry] = NULL;
  5.1631 -		return NULL;
  5.1632 -	}
  5.1633 -	rxf = sp->rx_ringp[entry] = (struct RxFD *)skb->tail;
  5.1634 -	sp->rx_ring_dma[entry] =
  5.1635 -		pci_map_single(sp->pdev, rxf,
  5.1636 -					   PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
  5.1637 -	skb->dev = dev;
  5.1638 -	skb_reserve(skb, sizeof(struct RxFD));
  5.1639 -	rxf->rx_buf_addr = 0xffffffff;
  5.1640 -	pci_dma_sync_single(sp->pdev, sp->rx_ring_dma[entry],
  5.1641 -			sizeof(struct RxFD), PCI_DMA_TODEVICE);
  5.1642 -	return rxf;
  5.1643 -}
  5.1644 -
  5.1645 -static inline void speedo_rx_link(struct net_device *dev, int entry,
  5.1646 -								  struct RxFD *rxf, dma_addr_t rxf_dma)
  5.1647 -{
  5.1648 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1649 -	rxf->status = cpu_to_le32(0xC0000001); 	/* '1' for driver use only. */
  5.1650 -	rxf->link = 0;			/* None yet. */
  5.1651 -	rxf->count = cpu_to_le32(PKT_BUF_SZ << 16);
  5.1652 -	sp->last_rxf->link = cpu_to_le32(rxf_dma);
  5.1653 -	sp->last_rxf->status &= cpu_to_le32(~0xC0000000);
  5.1654 -	pci_dma_sync_single(sp->pdev, sp->last_rxf_dma,
  5.1655 -			sizeof(struct RxFD), PCI_DMA_TODEVICE);
  5.1656 -	sp->last_rxf = rxf;
  5.1657 -	sp->last_rxf_dma = rxf_dma;
  5.1658 -}
  5.1659 -
  5.1660 -static int speedo_refill_rx_buf(struct net_device *dev, int force)
  5.1661 -{
  5.1662 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1663 -	int entry;
  5.1664 -	struct RxFD *rxf;
  5.1665 -
  5.1666 -	entry = sp->dirty_rx % RX_RING_SIZE;
  5.1667 -	if (sp->rx_skbuff[entry] == NULL) {
  5.1668 -		rxf = speedo_rx_alloc(dev, entry);
  5.1669 -		if (rxf == NULL) {
  5.1670 -			unsigned int forw;
  5.1671 -			int forw_entry;
  5.1672 -			if (speedo_debug > 2 || !(sp->rx_ring_state & RrOOMReported)) {
  5.1673 -				printk(KERN_WARNING "%s: can't fill rx buffer (force %d)!\n",
  5.1674 -						dev->name, force);
  5.1675 -				speedo_show_state(dev);
  5.1676 -				sp->rx_ring_state |= RrOOMReported;
  5.1677 -			}
  5.1678 -			if (!force)
  5.1679 -				return -1;	/* Better luck next time!  */
  5.1680 -			/* Borrow an skb from one of next entries. */
  5.1681 -			for (forw = sp->dirty_rx + 1; forw != sp->cur_rx; forw++)
  5.1682 -				if (sp->rx_skbuff[forw % RX_RING_SIZE] != NULL)
  5.1683 -					break;
  5.1684 -			if (forw == sp->cur_rx)
  5.1685 -				return -1;
  5.1686 -			forw_entry = forw % RX_RING_SIZE;
  5.1687 -			sp->rx_skbuff[entry] = sp->rx_skbuff[forw_entry];
  5.1688 -			sp->rx_skbuff[forw_entry] = NULL;
  5.1689 -			rxf = sp->rx_ringp[forw_entry];
  5.1690 -			sp->rx_ringp[forw_entry] = NULL;
  5.1691 -			sp->rx_ringp[entry] = rxf;
  5.1692 -		}
  5.1693 -	} else {
  5.1694 -		rxf = sp->rx_ringp[entry];
  5.1695 -	}
  5.1696 -	speedo_rx_link(dev, entry, rxf, sp->rx_ring_dma[entry]);
  5.1697 -	sp->dirty_rx++;
  5.1698 -	sp->rx_ring_state &= ~(RrNoMem|RrOOMReported); /* Mark the progress. */
  5.1699 -	return 0;
  5.1700 -}
  5.1701 -
  5.1702 -static void speedo_refill_rx_buffers(struct net_device *dev, int force)
  5.1703 -{
  5.1704 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1705 -
  5.1706 -	/* Refill the RX ring. */
  5.1707 -	while ((int)(sp->cur_rx - sp->dirty_rx) > 0 &&
  5.1708 -			speedo_refill_rx_buf(dev, force) != -1);
  5.1709 -}
  5.1710 -
  5.1711 -static int
  5.1712 -speedo_rx(struct net_device *dev)
  5.1713 -{
  5.1714 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1715 -	int entry = sp->cur_rx % RX_RING_SIZE;
  5.1716 -	int rx_work_limit = sp->dirty_rx + RX_RING_SIZE - sp->cur_rx;
  5.1717 -	int alloc_ok = 1;
  5.1718 -
  5.1719 -	if (speedo_debug > 4)
  5.1720 -		printk(KERN_DEBUG " In speedo_rx().\n");
  5.1721 -	/* If we own the next entry, it's a new packet. Send it up. */
  5.1722 -	while (sp->rx_ringp[entry] != NULL) {
  5.1723 -		int status;
  5.1724 -		int pkt_len;
  5.1725 -
  5.1726 -		pci_dma_sync_single(sp->pdev, sp->rx_ring_dma[entry],
  5.1727 -			sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
  5.1728 -		status = le32_to_cpu(sp->rx_ringp[entry]->status);
  5.1729 -		pkt_len = le32_to_cpu(sp->rx_ringp[entry]->count) & 0x3fff;
  5.1730 -
  5.1731 -		if (!(status & RxComplete))
  5.1732 -			break;
  5.1733 -
  5.1734 -		if (--rx_work_limit < 0)
  5.1735 -			break;
  5.1736 -
  5.1737 -		/* Check for a rare out-of-memory case: the current buffer is
  5.1738 -		   the last buffer allocated in the RX ring.  --SAW */
  5.1739 -		if (sp->last_rxf == sp->rx_ringp[entry]) {
  5.1740 -			/* Postpone the packet.  It'll be reaped at an interrupt when this
  5.1741 -			   packet is no longer the last packet in the ring. */
  5.1742 -			if (speedo_debug > 2)
  5.1743 -				printk(KERN_DEBUG "%s: RX packet postponed!\n",
  5.1744 -					   dev->name);
  5.1745 -			sp->rx_ring_state |= RrPostponed;
  5.1746 -			break;
  5.1747 -		}
  5.1748 -
  5.1749 -		if (speedo_debug > 4)
  5.1750 -			printk(KERN_DEBUG "  speedo_rx() status %8.8x len %d.\n", status,
  5.1751 -				   pkt_len);
  5.1752 -		if ((status & (RxErrTooBig|RxOK|0x0f90)) != RxOK) {
  5.1753 -			if (status & RxErrTooBig)
  5.1754 -				printk(KERN_ERR "%s: Ethernet frame overran the Rx buffer, "
  5.1755 -					   "status %8.8x!\n", dev->name, status);
  5.1756 -			else if (! (status & RxOK)) {
  5.1757 -				/* There was a fatal error.  This *should* be impossible. */
  5.1758 -				sp->stats.rx_errors++;
  5.1759 -				printk(KERN_ERR "%s: Anomalous event in speedo_rx(), "
  5.1760 -					   "status %8.8x.\n",
  5.1761 -					   dev->name, status);
  5.1762 -			}
  5.1763 -		} else {
  5.1764 -			struct sk_buff *skb;
  5.1765 -
  5.1766 -			/* Check if the packet is long enough to just accept without
  5.1767 -			   copying to a properly sized skbuff. */
  5.1768 -			if (pkt_len < rx_copybreak
  5.1769 -				&& (skb = dev_alloc_skb(pkt_len + 2)) != 0) {
  5.1770 -				skb->dev = dev;
  5.1771 -				skb_reserve(skb, 2);	/* Align IP on 16 byte boundaries */
  5.1772 -				/* 'skb_put()' points to the start of sk_buff data area. */
  5.1773 -				pci_dma_sync_single(sp->pdev, sp->rx_ring_dma[entry],
  5.1774 -					sizeof(struct RxFD) + pkt_len, PCI_DMA_FROMDEVICE);
  5.1775 -
  5.1776 -#if 1 || USE_IP_CSUM
  5.1777 -				/* Packet is in one chunk -- we can copy + cksum. */
  5.1778 -				eth_copy_and_sum(skb, sp->rx_skbuff[entry]->tail, pkt_len, 0);
  5.1779 -				skb_put(skb, pkt_len);
  5.1780 -#else
  5.1781 -				memcpy(skb_put(skb, pkt_len), sp->rx_skbuff[entry]->tail,
  5.1782 -					   pkt_len);
  5.1783 -#endif
  5.1784 -			} else {
  5.1785 -				/* Pass up the already-filled skbuff. */
  5.1786 -				skb = sp->rx_skbuff[entry];
  5.1787 -				if (skb == NULL) {
  5.1788 -					printk(KERN_ERR "%s: Inconsistent Rx descriptor chain.\n",
  5.1789 -						   dev->name);
  5.1790 -					break;
  5.1791 -				}
  5.1792 -				sp->rx_skbuff[entry] = NULL;
  5.1793 -				skb_put(skb, pkt_len);
  5.1794 -				sp->rx_ringp[entry] = NULL;
  5.1795 -				pci_unmap_single(sp->pdev, sp->rx_ring_dma[entry],
  5.1796 -						PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
  5.1797 -			}
  5.1798 -			skb->protocol = eth_type_trans(skb, dev);
  5.1799 -			netif_rx(skb);
  5.1800 -			sp->stats.rx_packets++;
  5.1801 -			sp->stats.rx_bytes += pkt_len;
  5.1802 -		}
  5.1803 -		entry = (++sp->cur_rx) % RX_RING_SIZE;
  5.1804 -		sp->rx_ring_state &= ~RrPostponed;
  5.1805 -		/* Refill the recently taken buffers.
  5.1806 -		   Do it one-by-one to handle traffic bursts better. */
  5.1807 -		if (alloc_ok && speedo_refill_rx_buf(dev, 0) == -1)
  5.1808 -			alloc_ok = 0;
  5.1809 -	}
  5.1810 -
  5.1811 -	/* Try hard to refill the recently taken buffers. */
  5.1812 -	speedo_refill_rx_buffers(dev, 1);
  5.1813 -
  5.1814 -	sp->last_rx_time = jiffies;
  5.1815 -
  5.1816 -	return 0;
  5.1817 -}
  5.1818 -
  5.1819 -static int
  5.1820 -speedo_close(struct net_device *dev)
  5.1821 -{
  5.1822 -	long ioaddr = dev->base_addr;
  5.1823 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1824 -	int i;
  5.1825 -
  5.1826 -	netdevice_stop(dev);
  5.1827 -	netif_stop_queue(dev);
  5.1828 -
  5.1829 -	if (speedo_debug > 1)
  5.1830 -		printk(KERN_DEBUG "%s: Shutting down ethercard, status was %4.4x.\n",
  5.1831 -			   dev->name, inw(ioaddr + SCBStatus));
  5.1832 -
  5.1833 -	/* Shut off the media monitoring timer. */
  5.1834 -	del_timer_sync(&sp->timer);
  5.1835 -
  5.1836 -	/* Shutting down the chip nicely fails to disable flow control. So.. */
  5.1837 -	outl(PortPartialReset, ioaddr + SCBPort);
  5.1838 -
  5.1839 -	free_irq(dev->irq, dev);
  5.1840 -
  5.1841 -	/* Print a few items for debugging. */
  5.1842 -	if (speedo_debug > 3)
  5.1843 -		speedo_show_state(dev);
  5.1844 -
  5.1845 -    /* Free all the skbuffs in the Rx and Tx queues. */
  5.1846 -	for (i = 0; i < RX_RING_SIZE; i++) {
  5.1847 -		struct sk_buff *skb = sp->rx_skbuff[i];
  5.1848 -		sp->rx_skbuff[i] = 0;
  5.1849 -		/* Clear the Rx descriptors. */
  5.1850 -		if (skb) {
  5.1851 -			pci_unmap_single(sp->pdev,
  5.1852 -					 sp->rx_ring_dma[i],
  5.1853 -					 PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
  5.1854 -			dev_kfree_skb(skb);
  5.1855 -		}
  5.1856 -	}
  5.1857 -
  5.1858 -	for (i = 0; i < TX_RING_SIZE; i++) {
  5.1859 -		struct sk_buff *skb = sp->tx_skbuff[i];
  5.1860 -		sp->tx_skbuff[i] = 0;
  5.1861 -		/* Clear the Tx descriptors. */
  5.1862 -		if (skb) {
  5.1863 -			pci_unmap_single(sp->pdev,
  5.1864 -					 le32_to_cpu(sp->tx_ring[i].tx_buf_addr0),
  5.1865 -					 skb->len, PCI_DMA_TODEVICE);
  5.1866 -			dev_kfree_skb(skb);
  5.1867 -		}
  5.1868 -	}
  5.1869 -
  5.1870 -	/* Free multicast setting blocks. */
  5.1871 -	for (i = 0; sp->mc_setup_head != NULL; i++) {
  5.1872 -		struct speedo_mc_block *t;
  5.1873 -		t = sp->mc_setup_head->next;
  5.1874 -		kfree(sp->mc_setup_head);
  5.1875 -		sp->mc_setup_head = t;
  5.1876 -	}
  5.1877 -	sp->mc_setup_tail = NULL;
  5.1878 -	if (speedo_debug > 0)
  5.1879 -		printk(KERN_DEBUG "%s: %d multicast blocks dropped.\n", dev->name, i);
  5.1880 -
  5.1881 -	SET_POWER_STATE(sp->pdev, 2);
  5.1882 -
  5.1883 -	MOD_DEC_USE_COUNT;
  5.1884 -
  5.1885 -	return 0;
  5.1886 -}
  5.1887 -
  5.1888 -/* The Speedo-3 has an especially awkward and unusable method of getting
  5.1889 -   statistics out of the chip.  It takes an unpredictable length of time
  5.1890 -   for the dump-stats command to complete.  To avoid a busy-wait loop we
  5.1891 -   update the stats with the previous dump results, and then trigger a
  5.1892 -   new dump.
  5.1893 -
  5.1894 -   Oh, and incoming frames are dropped while executing dump-stats!
  5.1895 -   */
  5.1896 -static struct net_device_stats *
  5.1897 -speedo_get_stats(struct net_device *dev)
  5.1898 -{
  5.1899 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1900 -	long ioaddr = dev->base_addr;
  5.1901 -
  5.1902 -	/* Update only if the previous dump finished. */
  5.1903 -	if (sp->lstats->done_marker == le32_to_cpu(0xA007)) {
  5.1904 -		sp->stats.tx_aborted_errors += le32_to_cpu(sp->lstats->tx_coll16_errs);
  5.1905 -		sp->stats.tx_window_errors += le32_to_cpu(sp->lstats->tx_late_colls);
  5.1906 -		sp->stats.tx_fifo_errors += le32_to_cpu(sp->lstats->tx_underruns);
  5.1907 -		sp->stats.tx_fifo_errors += le32_to_cpu(sp->lstats->tx_lost_carrier);
  5.1908 -		/*sp->stats.tx_deferred += le32_to_cpu(sp->lstats->tx_deferred);*/
  5.1909 -		sp->stats.collisions += le32_to_cpu(sp->lstats->tx_total_colls);
  5.1910 -		sp->stats.rx_crc_errors += le32_to_cpu(sp->lstats->rx_crc_errs);
  5.1911 -		sp->stats.rx_frame_errors += le32_to_cpu(sp->lstats->rx_align_errs);
  5.1912 -		sp->stats.rx_over_errors += le32_to_cpu(sp->lstats->rx_resource_errs);
  5.1913 -		sp->stats.rx_fifo_errors += le32_to_cpu(sp->lstats->rx_overrun_errs);
  5.1914 -		sp->stats.rx_length_errors += le32_to_cpu(sp->lstats->rx_runt_errs);
  5.1915 -		sp->lstats->done_marker = 0x0000;
  5.1916 -		if (netif_running(dev)) {
  5.1917 -			unsigned long flags;
  5.1918 -			/* Take a spinlock to make wait_for_cmd_done and sending the
  5.1919 -			   command atomic.  --SAW */
  5.1920 -			spin_lock_irqsave(&sp->lock, flags);
  5.1921 -			wait_for_cmd_done(ioaddr + SCBCmd);
  5.1922 -			outb(CUDumpStats, ioaddr + SCBCmd);
  5.1923 -			spin_unlock_irqrestore(&sp->lock, flags);
  5.1924 -		}
  5.1925 -	}
  5.1926 -	return &sp->stats;
  5.1927 -}
  5.1928 -
  5.1929 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
  5.1930 -{
  5.1931 -	u32 ethcmd;
  5.1932 -	struct speedo_private *sp = dev->priv;
  5.1933 -		
  5.1934 -	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
  5.1935 -		return -EFAULT;
  5.1936 -	
  5.1937 -        switch (ethcmd) {
  5.1938 -	case ETHTOOL_GDRVINFO: {
  5.1939 -		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
  5.1940 -		strncpy(info.driver, "eepro100", sizeof(info.driver)-1);
  5.1941 -		strncpy(info.version, version, sizeof(info.version)-1);
  5.1942 -		if (sp && sp->pdev)
  5.1943 -			strcpy(info.bus_info, sp->pdev->slot_name);
  5.1944 -		if (copy_to_user(useraddr, &info, sizeof(info)))
  5.1945 -			return -EFAULT;
  5.1946 -		return 0;
  5.1947 -	}
  5.1948 -	
  5.1949 -        }
  5.1950 -	
  5.1951 -	return -EOPNOTSUPP;
  5.1952 -}
  5.1953 -
  5.1954 -
  5.1955 -
  5.1956 -
  5.1957 -
  5.1958 -static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  5.1959 -{
  5.1960 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.1961 -	long ioaddr = dev->base_addr;
  5.1962 -	struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
  5.1963 -	int phy = sp->phy[0] & 0x1f;
  5.1964 -	int saved_acpi;
  5.1965 -	int t;
  5.1966 -
  5.1967 -    switch(cmd) {
  5.1968 -	case SIOCGMIIPHY:		/* Get address of MII PHY in use. */
  5.1969 -	case SIOCDEVPRIVATE:		/* for binary compat, remove in 2.5 */
  5.1970 -		data->phy_id = phy;
  5.1971 -
  5.1972 -	case SIOCGMIIREG:		/* Read MII PHY register. */
  5.1973 -	case SIOCDEVPRIVATE+1:		/* for binary compat, remove in 2.5 */
  5.1974 -		/* FIXME: these operations need to be serialized with MDIO
  5.1975 -		   access from the timeout handler.
  5.1976 -		   They are currently serialized only with MDIO access from the
  5.1977 -		   timer routine.  2000/05/09 SAW */
  5.1978 -		saved_acpi = SET_POWER_STATE(sp->pdev, 0);
  5.1979 -		t = del_timer_sync(&sp->timer);
  5.1980 -		data->val_out = mdio_read(ioaddr, data->phy_id & 0x1f, data->reg_num & 0x1f);
  5.1981 -		if (t)
  5.1982 -			add_timer(&sp->timer); /* may be set to the past  --SAW */
  5.1983 -		SET_POWER_STATE(sp->pdev, saved_acpi);
  5.1984 -		return 0;
  5.1985 -
  5.1986 -	case SIOCSMIIREG:		/* Write MII PHY register. */
  5.1987 -	case SIOCDEVPRIVATE+2:		/* for binary compat, remove in 2.5 */
  5.1988 -		if (!capable(CAP_NET_ADMIN))
  5.1989 -			return -EPERM;
  5.1990 -		saved_acpi = SET_POWER_STATE(sp->pdev, 0);
  5.1991 -		t = del_timer_sync(&sp->timer);
  5.1992 -		mdio_write(ioaddr, data->phy_id, data->reg_num, data->val_in);
  5.1993 -		if (t)
  5.1994 -			add_timer(&sp->timer); /* may be set to the past  --SAW */
  5.1995 -		SET_POWER_STATE(sp->pdev, saved_acpi);
  5.1996 -		return 0;
  5.1997 -	case SIOCETHTOOL:
  5.1998 -		return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
  5.1999 -	default:
  5.2000 -		return -EOPNOTSUPP;
  5.2001 -	}
  5.2002 -}
  5.2003 -
  5.2004 -/* Set or clear the multicast filter for this adaptor.
  5.2005 -   This is very ugly with Intel chips -- we usually have to execute an
  5.2006 -   entire configuration command, plus process a multicast command.
  5.2007 -   This is complicated.  We must put a large configuration command and
  5.2008 -   an arbitrarily-sized multicast command in the transmit list.
  5.2009 -   To minimize the disruption -- the previous command might have already
  5.2010 -   loaded the link -- we convert the current command block, normally a Tx
  5.2011 -   command, into a no-op and link it to the new command.
  5.2012 -*/
  5.2013 -static void set_rx_mode(struct net_device *dev)
  5.2014 -{
  5.2015 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.2016 -	long ioaddr = dev->base_addr;
  5.2017 -	struct descriptor *last_cmd;
  5.2018 -	char new_rx_mode;
  5.2019 -	unsigned long flags;
  5.2020 -	int entry, i;
  5.2021 -
  5.2022 -	if (dev->flags & IFF_PROMISC) {			/* Set promiscuous. */
  5.2023 -		new_rx_mode = 3;
  5.2024 -	} else if ((dev->flags & IFF_ALLMULTI)  ||
  5.2025 -			   dev->mc_count > multicast_filter_limit) {
  5.2026 -		new_rx_mode = 1;
  5.2027 -	} else
  5.2028 -		new_rx_mode = 0;
  5.2029 -
  5.2030 -	if (speedo_debug > 3)
  5.2031 -		printk(KERN_DEBUG "%s: set_rx_mode %d -> %d\n", dev->name,
  5.2032 -				sp->rx_mode, new_rx_mode);
  5.2033 -
  5.2034 -	if ((int)(sp->cur_tx - sp->dirty_tx) > TX_RING_SIZE - TX_MULTICAST_SIZE) {
  5.2035 -	    /* The Tx ring is full -- don't add anything!  Hope the mode will be
  5.2036 -		 * set again later. */
  5.2037 -		sp->rx_mode = -1;
  5.2038 -		return;
  5.2039 -	}
  5.2040 -
  5.2041 -	if (new_rx_mode != sp->rx_mode) {
  5.2042 -		u8 *config_cmd_data;
  5.2043 -
  5.2044 -		spin_lock_irqsave(&sp->lock, flags);
  5.2045 -		entry = sp->cur_tx++ % TX_RING_SIZE;
  5.2046 -		last_cmd = sp->last_cmd;
  5.2047 -		sp->last_cmd = (struct descriptor *)&sp->tx_ring[entry];
  5.2048 -
  5.2049 -		sp->tx_skbuff[entry] = 0;			/* Redundant. */
  5.2050 -		sp->tx_ring[entry].status = cpu_to_le32(CmdSuspend | CmdConfigure);
  5.2051 -		sp->tx_ring[entry].link =
  5.2052 -			cpu_to_le32(TX_RING_ELEM_DMA(sp, (entry + 1) % TX_RING_SIZE));
  5.2053 -		config_cmd_data = (void *)&sp->tx_ring[entry].tx_desc_addr;
  5.2054 -		/* Construct a full CmdConfig frame. */
  5.2055 -		memcpy(config_cmd_data, i82558_config_cmd, CONFIG_DATA_SIZE);
  5.2056 -		config_cmd_data[1] = (txfifo << 4) | rxfifo;
  5.2057 -		config_cmd_data[4] = rxdmacount;
  5.2058 -		config_cmd_data[5] = txdmacount + 0x80;
  5.2059 -		config_cmd_data[15] |= (new_rx_mode & 2) ? 1 : 0;
  5.2060 -		/* 0x80 doesn't disable FC 0x84 does.
  5.2061 -		   Disable Flow control since we are not ACK-ing any FC interrupts
  5.2062 -		   for now. --Dragan */
  5.2063 -		config_cmd_data[19] = 0x84;
  5.2064 -		config_cmd_data[19] |= sp->full_duplex ? 0x40 : 0;
  5.2065 -		config_cmd_data[21] = (new_rx_mode & 1) ? 0x0D : 0x05;
  5.2066 -		if (sp->phy[0] & 0x8000) {			/* Use the AUI port instead. */
  5.2067 -			config_cmd_data[15] |= 0x80;
  5.2068 -			config_cmd_data[8] = 0;
  5.2069 -		}
  5.2070 -		/* Trigger the command unit resume. */
  5.2071 -		wait_for_cmd_done(ioaddr + SCBCmd);
  5.2072 -		clear_suspend(last_cmd);
  5.2073 -		outb(CUResume, ioaddr + SCBCmd);
  5.2074 -		if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
  5.2075 -			netif_stop_queue(dev);
  5.2076 -			sp->tx_full = 1;
  5.2077 -		}
  5.2078 -		spin_unlock_irqrestore(&sp->lock, flags);
  5.2079 -	}
  5.2080 -
  5.2081 -	if (new_rx_mode == 0  &&  dev->mc_count < 4) {
  5.2082 -		/* The simple case of 0-3 multicast list entries occurs often, and
  5.2083 -		   fits within one tx_ring[] entry. */
  5.2084 -		struct dev_mc_list *mclist;
  5.2085 -		u16 *setup_params, *eaddrs;
  5.2086 -
  5.2087 -		spin_lock_irqsave(&sp->lock, flags);
  5.2088 -		entry = sp->cur_tx++ % TX_RING_SIZE;
  5.2089 -		last_cmd = sp->last_cmd;
  5.2090 -		sp->last_cmd = (struct descriptor *)&sp->tx_ring[entry];
  5.2091 -
  5.2092 -		sp->tx_skbuff[entry] = 0;
  5.2093 -		sp->tx_ring[entry].status = cpu_to_le32(CmdSuspend | CmdMulticastList);
  5.2094 -		sp->tx_ring[entry].link =
  5.2095 -			cpu_to_le32(TX_RING_ELEM_DMA(sp, (entry + 1) % TX_RING_SIZE));
  5.2096 -		sp->tx_ring[entry].tx_desc_addr = 0; /* Really MC list count. */
  5.2097 -		setup_params = (u16 *)&sp->tx_ring[entry].tx_desc_addr;
  5.2098 -		*setup_params++ = cpu_to_le16(dev->mc_count*6);
  5.2099 -		/* Fill in the multicast addresses. */
  5.2100 -		for (i = 0, mclist = dev->mc_list; i < dev->mc_count;
  5.2101 -			 i++, mclist = mclist->next) {
  5.2102 -			eaddrs = (u16 *)mclist->dmi_addr;
  5.2103 -			*setup_params++ = *eaddrs++;
  5.2104 -			*setup_params++ = *eaddrs++;
  5.2105 -			*setup_params++ = *eaddrs++;
  5.2106 -		}
  5.2107 -
  5.2108 -		wait_for_cmd_done(ioaddr + SCBCmd);
  5.2109 -		clear_suspend(last_cmd);
  5.2110 -		/* Immediately trigger the command unit resume. */
  5.2111 -		outb(CUResume, ioaddr + SCBCmd);
  5.2112 -
  5.2113 -		if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
  5.2114 -			netif_stop_queue(dev);
  5.2115 -			sp->tx_full = 1;
  5.2116 -		}
  5.2117 -		spin_unlock_irqrestore(&sp->lock, flags);
  5.2118 -	} else if (new_rx_mode == 0) {
  5.2119 -		struct dev_mc_list *mclist;
  5.2120 -		u16 *setup_params, *eaddrs;
  5.2121 -		struct speedo_mc_block *mc_blk;
  5.2122 -		struct descriptor *mc_setup_frm;
  5.2123 -		int i;
  5.2124 -
  5.2125 -		mc_blk = kmalloc(sizeof(*mc_blk) + 2 + multicast_filter_limit*6,
  5.2126 -						 GFP_ATOMIC);
  5.2127 -		if (mc_blk == NULL) {
  5.2128 -			printk(KERN_ERR "%s: Failed to allocate a setup frame.\n",
  5.2129 -				   dev->name);
  5.2130 -			sp->rx_mode = -1; /* We failed, try again. */
  5.2131 -			return;
  5.2132 -		}
  5.2133 -		mc_blk->next = NULL;
  5.2134 -		mc_blk->len = 2 + multicast_filter_limit*6;
  5.2135 -		mc_blk->frame_dma =
  5.2136 -			pci_map_single(sp->pdev, &mc_blk->frame, mc_blk->len,
  5.2137 -					PCI_DMA_TODEVICE);
  5.2138 -		mc_setup_frm = &mc_blk->frame;
  5.2139 -
  5.2140 -		/* Fill the setup frame. */
  5.2141 -		if (speedo_debug > 1)
  5.2142 -			printk(KERN_DEBUG "%s: Constructing a setup frame at %p.\n",
  5.2143 -				   dev->name, mc_setup_frm);
  5.2144 -		mc_setup_frm->cmd_status =
  5.2145 -			cpu_to_le32(CmdSuspend | CmdIntr | CmdMulticastList);
  5.2146 -		/* Link set below. */
  5.2147 -		setup_params = (u16 *)&mc_setup_frm->params;
  5.2148 -		*setup_params++ = cpu_to_le16(dev->mc_count*6);
  5.2149 -		/* Fill in the multicast addresses. */
  5.2150 -		for (i = 0, mclist = dev->mc_list; i < dev->mc_count;
  5.2151 -			 i++, mclist = mclist->next) {
  5.2152 -			eaddrs = (u16 *)mclist->dmi_addr;
  5.2153 -			*setup_params++ = *eaddrs++;
  5.2154 -			*setup_params++ = *eaddrs++;
  5.2155 -			*setup_params++ = *eaddrs++;
  5.2156 -		}
  5.2157 -
  5.2158 -		/* Disable interrupts while playing with the Tx Cmd list. */
  5.2159 -		spin_lock_irqsave(&sp->lock, flags);
  5.2160 -
  5.2161 -		if (sp->mc_setup_tail)
  5.2162 -			sp->mc_setup_tail->next = mc_blk;
  5.2163 -		else
  5.2164 -			sp->mc_setup_head = mc_blk;
  5.2165 -		sp->mc_setup_tail = mc_blk;
  5.2166 -		mc_blk->tx = sp->cur_tx;
  5.2167 -
  5.2168 -		entry = sp->cur_tx++ % TX_RING_SIZE;
  5.2169 -		last_cmd = sp->last_cmd;
  5.2170 -		sp->last_cmd = mc_setup_frm;
  5.2171 -
  5.2172 -		/* Change the command to a NoOp, pointing to the CmdMulti command. */
  5.2173 -		sp->tx_skbuff[entry] = 0;
  5.2174 -		sp->tx_ring[entry].status = cpu_to_le32(CmdNOp);
  5.2175 -		sp->tx_ring[entry].link = cpu_to_le32(mc_blk->frame_dma);
  5.2176 -
  5.2177 -		/* Set the link in the setup frame. */
  5.2178 -		mc_setup_frm->link =
  5.2179 -			cpu_to_le32(TX_RING_ELEM_DMA(sp, (entry + 1) % TX_RING_SIZE));
  5.2180 -
  5.2181 -		pci_dma_sync_single(sp->pdev, mc_blk->frame_dma,
  5.2182 -				mc_blk->len, PCI_DMA_TODEVICE);
  5.2183 -
  5.2184 -		wait_for_cmd_done(ioaddr + SCBCmd);
  5.2185 -		clear_suspend(last_cmd);
  5.2186 -		/* Immediately trigger the command unit resume. */
  5.2187 -		outb(CUResume, ioaddr + SCBCmd);
  5.2188 -
  5.2189 -		if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
  5.2190 -			netif_stop_queue(dev);
  5.2191 -			sp->tx_full = 1;
  5.2192 -		}
  5.2193 -		spin_unlock_irqrestore(&sp->lock, flags);
  5.2194 -
  5.2195 -		if (speedo_debug > 5)
  5.2196 -			printk(" CmdMCSetup frame length %d in entry %d.\n",
  5.2197 -				   dev->mc_count, entry);
  5.2198 -	}
  5.2199 -
  5.2200 -	sp->rx_mode = new_rx_mode;
  5.2201 -}
  5.2202 -
  5.2203 -#ifdef CONFIG_PM
  5.2204 -static int eepro100_suspend(struct pci_dev *pdev, u32 state)
  5.2205 -{
  5.2206 -	struct net_device *dev = pci_get_drvdata (pdev);
  5.2207 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.2208 -	long ioaddr = dev->base_addr;
  5.2209 -
  5.2210 -	pci_save_state(pdev, sp->pm_state);
  5.2211 -
  5.2212 -	if (!netif_running(dev))
  5.2213 -		return 0;
  5.2214 -
  5.2215 -	netif_device_detach(dev);
  5.2216 -	outl(PortPartialReset, ioaddr + SCBPort);
  5.2217 -	
  5.2218 -	/* XXX call SET_POWER_STATE ()? */
  5.2219 -	return 0;
  5.2220 -}
  5.2221 -
  5.2222 -static int eepro100_resume(struct pci_dev *pdev)
  5.2223 -{
  5.2224 -	struct net_device *dev = pci_get_drvdata (pdev);
  5.2225 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.2226 -	long ioaddr = dev->base_addr;
  5.2227 -
  5.2228 -	pci_restore_state(pdev, sp->pm_state);
  5.2229 -
  5.2230 -	if (!netif_running(dev))
  5.2231 -		return 0;
  5.2232 -
  5.2233 -	/* I'm absolutely uncertain if this part of code may work.
  5.2234 -	   The problems are:
  5.2235 -	    - correct hardware reinitialization;
  5.2236 -		- correct driver behavior between different steps of the
  5.2237 -		  reinitialization;
  5.2238 -		- serialization with other driver calls.
  5.2239 -	   2000/03/08  SAW */
  5.2240 -	outw(SCBMaskAll, ioaddr + SCBCmd);
  5.2241 -	speedo_resume(dev);
  5.2242 -	netif_device_attach(dev);
  5.2243 -	sp->rx_mode = -1;
  5.2244 -	sp->flow_ctrl = sp->partner = 0;
  5.2245 -	set_rx_mode(dev);
  5.2246 -	return 0;
  5.2247 -}
  5.2248 -#endif /* CONFIG_PM */
  5.2249 -
  5.2250 -static void __devexit eepro100_remove_one (struct pci_dev *pdev)
  5.2251 -{
  5.2252 -	struct net_device *dev = pci_get_drvdata (pdev);
  5.2253 -	struct speedo_private *sp = (struct speedo_private *)dev->priv;
  5.2254 -	
  5.2255 -	unregister_netdev(dev);
  5.2256 -
  5.2257 -	release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1));
  5.2258 -	release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
  5.2259 -
  5.2260 -#ifndef USE_IO
  5.2261 -	iounmap((char *)dev->base_addr);
  5.2262 -#endif
  5.2263 -
  5.2264 -	pci_free_consistent(pdev, TX_RING_SIZE * sizeof(struct TxFD)
  5.2265 -								+ sizeof(struct speedo_stats),
  5.2266 -						sp->tx_ring, sp->tx_ring_dma);
  5.2267 -	pci_disable_device(pdev);
  5.2268 -	kfree(dev);
  5.2269 -}
  5.2270 -
  5.2271 -static struct pci_device_id eepro100_pci_tbl[] __devinitdata = {
  5.2272 -	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557,
  5.2273 -		PCI_ANY_ID, PCI_ANY_ID, },
  5.2274 -	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82562ET,
  5.2275 -		PCI_ANY_ID, PCI_ANY_ID, },
  5.2276 -	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER,
  5.2277 -		PCI_ANY_ID, PCI_ANY_ID, },
  5.2278 -	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1029,
  5.2279 -		PCI_ANY_ID, PCI_ANY_ID, },
  5.2280 -	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1030,
  5.2281 -		PCI_ANY_ID, PCI_ANY_ID, },
  5.2282 -	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_7,
  5.2283 -		PCI_ANY_ID, PCI_ANY_ID, },
  5.2284 -	{ 0,}
  5.2285 -};
  5.2286 -MODULE_DEVICE_TABLE(pci, eepro100_pci_tbl);
  5.2287 -	
  5.2288 -static struct pci_driver eepro100_driver = {
  5.2289 -	name:		"eepro100",
  5.2290 -	id_table:	eepro100_pci_tbl,
  5.2291 -	probe:		eepro100_init_one,
  5.2292 -	remove:		__devexit_p(eepro100_remove_one),
  5.2293 -#ifdef CONFIG_PM
  5.2294 -	suspend:	eepro100_suspend,
  5.2295 -	resume:		eepro100_resume,
  5.2296 -#endif /* CONFIG_PM */
  5.2297 -};
  5.2298 -
  5.2299 -static int __init eepro100_init_module(void)
  5.2300 -{
  5.2301 -	if (debug >= 0 && speedo_debug != debug)
  5.2302 -		printk(KERN_INFO "eepro100.c: Debug level is %d.\n", debug);
  5.2303 -	if (debug >= 0)
  5.2304 -		speedo_debug = debug;
  5.2305 -
  5.2306 -	return pci_module_init(&eepro100_driver);
  5.2307 -}
  5.2308 -
  5.2309 -static void __exit eepro100_cleanup_module(void)
  5.2310 -{
  5.2311 -	pci_unregister_driver(&eepro100_driver);
  5.2312 -}
  5.2313 -
  5.2314 -module_init(eepro100_init_module);
  5.2315 -module_exit(eepro100_cleanup_module);
     6.1 --- a/xen-2.4.16/drivers/net/pcnet32.c	Fri Feb 14 17:11:31 2003 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,1614 +0,0 @@
     6.4 -/* pcnet32.c: An AMD PCnet32 ethernet driver for linux. */
     6.5 -/*
     6.6 - *	Copyright 1996-1999 Thomas Bogendoerfer
     6.7 - * 
     6.8 - *	Derived from the lance driver written 1993,1994,1995 by Donald Becker.
     6.9 - * 
    6.10 - *	Copyright 1993 United States Government as represented by the
    6.11 - *	Director, National Security Agency.
    6.12 - * 
    6.13 - *	This software may be used and distributed according to the terms
    6.14 - *	of the GNU General Public License, incorporated herein by reference.
    6.15 - *
    6.16 - *	This driver is for PCnet32 and PCnetPCI based ethercards
    6.17 - */
    6.18 -/**************************************************************************
    6.19 - *  23 Oct, 2000.
    6.20 - *  Fixed a few bugs, related to running the controller in 32bit mode.
    6.21 - *
    6.22 - *  Carsten Langgaard, carstenl@mips.com
    6.23 - *  Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
    6.24 - *
    6.25 - *************************************************************************/
    6.26 -
    6.27 -static const char *version = "pcnet32.c:v1.25kf 26.9.1999 tsbogend@alpha.franken.de\n";
    6.28 -
    6.29 -#include <linux/config.h>
    6.30 -#include <linux/types.h>
    6.31 -#include <linux/lib.h>
    6.32 -
    6.33 -#include <linux/module.h>
    6.34 -
    6.35 -//#include <linux/kernel.h>
    6.36 -#include <linux/sched.h>
    6.37 -//#include <linux/string.h>
    6.38 -//#include <linux/ptrace.h>
    6.39 -#include <linux/errno.h>
    6.40 -#include <linux/ioport.h>
    6.41 -#include <linux/slab.h>
    6.42 -#include <linux/interrupt.h>
    6.43 -#include <linux/pci.h>
    6.44 -#include <linux/delay.h>
    6.45 -#include <linux/init.h>
    6.46 -#include <asm/bitops.h>
    6.47 -#include <asm/io.h>
    6.48 -//#include <asm/dma.h>
    6.49 -
    6.50 -#include <linux/netdevice.h>
    6.51 -#include <linux/etherdevice.h>
    6.52 -#include <linux/skbuff.h>
    6.53 -#include <linux/spinlock.h>
    6.54 -
    6.55 -static unsigned int pcnet32_portlist[] __initdata = {0x300, 0x320, 0x340, 0x360, 0};
    6.56 -
    6.57 -/*
    6.58 - * PCI device identifiers for "new style" Linux PCI Device Drivers
    6.59 - */
    6.60 -static struct pci_device_id pcnet32_pci_tbl[] __devinitdata = {
    6.61 -    { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE_HOME, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
    6.62 -    { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
    6.63 -    { 0, }
    6.64 -};
    6.65 -
    6.66 -static int pcnet32_debug = 1;
    6.67 -static int tx_start = 1; /* Mapping -- 0:20, 1:64, 2:128, 3:~220 (depends on chip vers) */
    6.68 -
    6.69 -static struct net_device *pcnet32_dev;
    6.70 -
    6.71 -static const int max_interrupt_work = 80;
    6.72 -static const int rx_copybreak = 0; /* 200; Xen doesn't do in-driver copybreak. */
    6.73 -
    6.74 -#define PORT_AUI      0x00
    6.75 -#define PORT_10BT     0x01
    6.76 -#define PORT_GPSI     0x02
    6.77 -#define PORT_MII      0x03
    6.78 -
    6.79 -#define PORT_PORTSEL  0x03
    6.80 -#define PORT_ASEL     0x04
    6.81 -#define PORT_100      0x40
    6.82 -#define PORT_FD	      0x80
    6.83 -
    6.84 -#define PCNET32_DMA_MASK 0xffffffff
    6.85 -
    6.86 -/*
    6.87 - * table to translate option values from tulip
    6.88 - * to internal options
    6.89 - */
    6.90 -static unsigned char options_mapping[] = {
    6.91 -    PORT_ASEL,			   /*  0 Auto-select	  */
    6.92 -    PORT_AUI,			   /*  1 BNC/AUI	  */
    6.93 -    PORT_AUI,			   /*  2 AUI/BNC	  */ 
    6.94 -    PORT_ASEL,			   /*  3 not supported	  */
    6.95 -    PORT_10BT | PORT_FD,	   /*  4 10baseT-FD	  */
    6.96 -    PORT_ASEL,			   /*  5 not supported	  */
    6.97 -    PORT_ASEL,			   /*  6 not supported	  */
    6.98 -    PORT_ASEL,			   /*  7 not supported	  */
    6.99 -    PORT_ASEL,			   /*  8 not supported	  */
   6.100 -    PORT_MII,			   /*  9 MII 10baseT	  */
   6.101 -    PORT_MII | PORT_FD,		   /* 10 MII 10baseT-FD	  */
   6.102 -    PORT_MII,			   /* 11 MII (autosel)	  */
   6.103 -    PORT_10BT,			   /* 12 10BaseT	  */
   6.104 -    PORT_MII | PORT_100,	   /* 13 MII 100BaseTx	  */
   6.105 -    PORT_MII | PORT_100 | PORT_FD, /* 14 MII 100BaseTx-FD */
   6.106 -    PORT_ASEL			   /* 15 not supported	  */
   6.107 -};
   6.108 -
   6.109 -#define MAX_UNITS 8
   6.110 -static int options[MAX_UNITS];
   6.111 -static int full_duplex[MAX_UNITS];
   6.112 -
   6.113 -/*
   6.114 - *				Theory of Operation
   6.115 - * 
   6.116 - * This driver uses the same software structure as the normal lance
   6.117 - * driver. So look for a verbose description in lance.c. The differences
   6.118 - * to the normal lance driver is the use of the 32bit mode of PCnet32
   6.119 - * and PCnetPCI chips. Because these chips are 32bit chips, there is no
   6.120 - * 16MB limitation and we don't need bounce buffers.
   6.121 - */
   6.122 - 
   6.123 -/*
   6.124 - * History:
   6.125 - * v0.01:  Initial version
   6.126 - *	   only tested on Alpha Noname Board
   6.127 - * v0.02:  changed IRQ handling for new interrupt scheme (dev_id)
   6.128 - *	   tested on a ASUS SP3G
   6.129 - * v0.10:  fixed an odd problem with the 79C974 in a Compaq Deskpro XL
   6.130 - *	   looks like the 974 doesn't like stopping and restarting in a
   6.131 - *	   short period of time; now we do a reinit of the lance; the
   6.132 - *	   bug was triggered by doing ifconfig eth0 <ip> broadcast <addr>
   6.133 - *	   and hangs the machine (thanks to Klaus Liedl for debugging)
   6.134 - * v0.12:  by suggestion from Donald Becker: Renamed driver to pcnet32,
   6.135 - *	   made it standalone (no need for lance.c)
   6.136 - * v0.13:  added additional PCI detecting for special PCI devices (Compaq)
   6.137 - * v0.14:  stripped down additional PCI probe (thanks to David C Niemi
   6.138 - *	   and sveneric@xs4all.nl for testing this on their Compaq boxes)
   6.139 - * v0.15:  added 79C965 (VLB) probe
   6.140 - *	   added interrupt sharing for PCI chips
   6.141 - * v0.16:  fixed set_multicast_list on Alpha machines
   6.142 - * v0.17:  removed hack from dev.c; now pcnet32 uses ethif_probe in Space.c
   6.143 - * v0.19:  changed setting of autoselect bit
   6.144 - * v0.20:  removed additional Compaq PCI probe; there is now a working one
   6.145 - *	   in arch/i386/bios32.c
   6.146 - * v0.21:  added endian conversion for ppc, from work by cort@cs.nmt.edu
   6.147 - * v0.22:  added printing of status to ring dump
   6.148 - * v0.23:  changed enet_statistics to net_devive_stats
   6.149 - * v0.90:  added multicast filter
   6.150 - *	   added module support
   6.151 - *	   changed irq probe to new style
   6.152 - *	   added PCnetFast chip id
   6.153 - *	   added fix for receive stalls with Intel saturn chipsets
   6.154 - *	   added in-place rx skbs like in the tulip driver
   6.155 - *	   minor cleanups
   6.156 - * v0.91:  added PCnetFast+ chip id
   6.157 - *	   back port to 2.0.x
   6.158 - * v1.00:  added some stuff from Donald Becker's 2.0.34 version
   6.159 - *	   added support for byte counters in net_dev_stats
   6.160 - * v1.01:  do ring dumps, only when debugging the driver
   6.161 - *	   increased the transmit timeout
   6.162 - * v1.02:  fixed memory leak in pcnet32_init_ring()
   6.163 - * v1.10:  workaround for stopped transmitter
   6.164 - *	   added port selection for modules
   6.165 - *	   detect special T1/E1 WAN card and setup port selection
   6.166 - * v1.11:  fixed wrong checking of Tx errors
   6.167 - * v1.20:  added check of return value kmalloc (cpeterso@cs.washington.edu)
   6.168 - *	   added save original kmalloc addr for freeing (mcr@solidum.com)
   6.169 - *	   added support for PCnetHome chip (joe@MIT.EDU)
   6.170 - *	   rewritten PCI card detection
   6.171 - *	   added dwio mode to get driver working on some PPC machines
   6.172 - * v1.21:  added mii selection and mii ioctl
   6.173 - * v1.22:  changed pci scanning code to make PPC people happy
   6.174 - *	   fixed switching to 32bit mode in pcnet32_open() (thanks
   6.175 - *	   to Michael Richard <mcr@solidum.com> for noticing this one)
   6.176 - *	   added sub vendor/device id matching (thanks again to 
   6.177 - *	   Michael Richard <mcr@solidum.com>)
   6.178 - *	   added chip id for 79c973/975 (thanks to Zach Brown <zab@zabbo.net>)
   6.179 - * v1.23   fixed small bug, when manual selecting MII speed/duplex
   6.180 - * v1.24   Applied Thomas' patch to use TxStartPoint and thus decrease TxFIFO
   6.181 - *	   underflows.	Added tx_start_pt module parameter. Increased
   6.182 - *	   TX_RING_SIZE from 16 to 32.	Added #ifdef'd code to use DXSUFLO
   6.183 - *	   for FAST[+] chipsets. <kaf@fc.hp.com>
   6.184 - * v1.24ac Added SMP spinlocking - Alan Cox <alan@redhat.com>
   6.185 - * v1.25kf Added No Interrupt on successful Tx for some Tx's <kaf@fc.hp.com>
   6.186 - * v1.26   Converted to pci_alloc_consistent, Jamey Hicks / George France
   6.187 - *                                           <jamey@crl.dec.com>
   6.188 - * v1.26p Fix oops on rmmod+insmod; plug i/o resource leak - Paul Gortmaker
   6.189 - */
   6.190 -
   6.191 -
   6.192 -/*
   6.193 - * Set the number of Tx and Rx buffers, using Log_2(# buffers).
   6.194 - * Reasonable default values are 4 Tx buffers, and 16 Rx buffers.
   6.195 - * That translates to 2 (4 == 2^^2) and 4 (16 == 2^^4).
   6.196 - */
   6.197 -#ifndef PCNET32_LOG_TX_BUFFERS
   6.198 -#define PCNET32_LOG_TX_BUFFERS 4
   6.199 -#define PCNET32_LOG_RX_BUFFERS 5
   6.200 -#endif
   6.201 -
   6.202 -#undef RX_RING_SIZE
   6.203 -#undef TX_RING_SIZE
   6.204 -
   6.205 -#define TX_RING_SIZE			(1 << (PCNET32_LOG_TX_BUFFERS))
   6.206 -#define TX_RING_MOD_MASK		(TX_RING_SIZE - 1)
   6.207 -#define TX_RING_LEN_BITS		((PCNET32_LOG_TX_BUFFERS) << 12)
   6.208 -
   6.209 -#define RX_RING_SIZE			(1 << (PCNET32_LOG_RX_BUFFERS))
   6.210 -#define RX_RING_MOD_MASK		(RX_RING_SIZE - 1)
   6.211 -#define RX_RING_LEN_BITS		((PCNET32_LOG_RX_BUFFERS) << 4)
   6.212 -
   6.213 -#define PKT_BUF_SZ		1544
   6.214 -
   6.215 -/* Offsets from base I/O address. */
   6.216 -#define PCNET32_WIO_RDP		0x10
   6.217 -#define PCNET32_WIO_RAP		0x12
   6.218 -#define PCNET32_WIO_RESET	0x14
   6.219 -#define PCNET32_WIO_BDP		0x16
   6.220 -
   6.221 -#define PCNET32_DWIO_RDP	0x10
   6.222 -#define PCNET32_DWIO_RAP	0x14
   6.223 -#define PCNET32_DWIO_RESET	0x18
   6.224 -#define PCNET32_DWIO_BDP	0x1C
   6.225 -
   6.226 -#define PCNET32_TOTAL_SIZE 0x20
   6.227 -
   6.228 -#define CRC_POLYNOMIAL_LE 0xedb88320UL	/* Ethernet CRC, little endian */
   6.229 -
   6.230 -/* The PCNET32 Rx and Tx ring descriptors. */
   6.231 -struct pcnet32_rx_head {
   6.232 -    u32 base;
   6.233 -    s16 buf_length;
   6.234 -    s16 status;	   
   6.235 -    u32 msg_length;
   6.236 -    u32 reserved;
   6.237 -};
   6.238 -	
   6.239 -struct pcnet32_tx_head {
   6.240 -    u32 base;
   6.241 -    s16 length;
   6.242 -    s16 status;
   6.243 -    u32 misc;
   6.244 -    u32 reserved;
   6.245 -};
   6.246 -
   6.247 -/* The PCNET32 32-Bit initialization block, described in databook. */
   6.248 -struct pcnet32_init_block {
   6.249 -    u16 mode;
   6.250 -    u16 tlen_rlen;
   6.251 -    u8	phys_addr[6];
   6.252 -    u16 reserved;
   6.253 -    u32 filter[2];
   6.254 -    /* Receive and transmit ring base, along with extra bits. */    
   6.255 -    u32 rx_ring;
   6.256 -    u32 tx_ring;
   6.257 -};
   6.258 -
   6.259 -/* PCnet32 access functions */
   6.260 -struct pcnet32_access {
   6.261 -    u16 (*read_csr)(unsigned long, int);
   6.262 -    void (*write_csr)(unsigned long, int, u16);
   6.263 -    u16 (*read_bcr)(unsigned long, int);
   6.264 -    void (*write_bcr)(unsigned long, int, u16);
   6.265 -    u16 (*read_rap)(unsigned long);
   6.266 -    void (*write_rap)(unsigned long, u16);
   6.267 -    void (*reset)(unsigned long);
   6.268 -};
   6.269 -
   6.270 -/*
   6.271 - * The first three fields of pcnet32_private are read by the ethernet device 
   6.272 - * so we allocate the structure should be allocated by pci_alloc_consistent().
   6.273 - */
   6.274 -struct pcnet32_private {
   6.275 -    /* The Tx and Rx ring entries must be aligned on 16-byte boundaries in 32bit mode. */
   6.276 -    struct pcnet32_rx_head   rx_ring[RX_RING_SIZE];
   6.277 -    struct pcnet32_tx_head   tx_ring[TX_RING_SIZE];
   6.278 -    struct pcnet32_init_block	init_block;
   6.279 -    dma_addr_t dma_addr;		/* DMA address of beginning of this object, returned by pci_alloc_consistent */
   6.280 -    struct pci_dev *pci_dev;		/* Pointer to the associated pci device structure */
   6.281 -    const char *name;
   6.282 -    /* The saved address of a sent-in-place packet/buffer, for skfree(). */
   6.283 -    struct sk_buff *tx_skbuff[TX_RING_SIZE];
   6.284 -    struct sk_buff *rx_skbuff[RX_RING_SIZE];
   6.285 -    dma_addr_t tx_dma_addr[TX_RING_SIZE];
   6.286 -    dma_addr_t rx_dma_addr[RX_RING_SIZE];
   6.287 -    struct pcnet32_access a;
   6.288 -    spinlock_t lock;					/* Guard lock */
   6.289 -    unsigned int cur_rx, cur_tx;		/* The next free ring entry */
   6.290 -    unsigned int dirty_rx, dirty_tx;	/* The ring entries to be free()ed. */
   6.291 -    struct net_device_stats stats;
   6.292 -    char tx_full;
   6.293 -    int	 options;
   6.294 -    int	 shared_irq:1,			/* shared irq possible */
   6.295 -	ltint:1,
   6.296 -#ifdef DO_DXSUFLO
   6.297 -	      dxsuflo:1,						    /* disable transmit stop on uflo */
   6.298 -#endif
   6.299 -	full_duplex:1,				/* full duplex possible */
   6.300 -	mii:1;					/* mii port available */
   6.301 -    struct net_device *next;
   6.302 -};
   6.303 -
   6.304 -static int  pcnet32_probe_vlbus(int cards_found);
   6.305 -static int  pcnet32_probe_pci(struct pci_dev *, const struct pci_device_id *);
   6.306 -static int  pcnet32_probe1(unsigned long, unsigned char, int, int, struct pci_dev *);
   6.307 -static int  pcnet32_open(struct net_device *);
   6.308 -static int  pcnet32_init_ring(struct net_device *);
   6.309 -static int  pcnet32_start_xmit(struct sk_buff *, struct net_device *);
   6.310 -static int  pcnet32_rx(struct net_device *);
   6.311 -static void pcnet32_tx_timeout (struct net_device *dev);
   6.312 -static void pcnet32_interrupt(int, void *, struct pt_regs *);
   6.313 -static int  pcnet32_close(struct net_device *);
   6.314 -static struct net_device_stats *pcnet32_get_stats(struct net_device *);
   6.315 -static void pcnet32_set_multicast_list(struct net_device *);
   6.316 -#ifdef HAVE_PRIVATE_IOCTL
   6.317 -static int  pcnet32_mii_ioctl(struct net_device *, struct ifreq *, int);
   6.318 -#endif
   6.319 -
   6.320 -enum pci_flags_bit {
   6.321 -    PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
   6.322 -    PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
   6.323 -};
   6.324 -
   6.325 -struct pcnet32_pci_id_info {
   6.326 -    const char *name;
   6.327 -    u16 vendor_id, device_id, svid, sdid, flags;
   6.328 -    int io_size;
   6.329 -    int (*probe1) (unsigned long, unsigned char, int, int, struct pci_dev *);
   6.330 -};
   6.331 -
   6.332 -
   6.333 -MODULE_DEVICE_TABLE (pci, pcnet32_pci_tbl);
   6.334 -
   6.335 -static u16 pcnet32_wio_read_csr (unsigned long addr, int index)
   6.336 -{
   6.337 -    outw (index, addr+PCNET32_WIO_RAP);
   6.338 -    return inw (addr+PCNET32_WIO_RDP);
   6.339 -}
   6.340 -
   6.341 -static void pcnet32_wio_write_csr (unsigned long addr, int index, u16 val)
   6.342 -{
   6.343 -    outw (index, addr+PCNET32_WIO_RAP);
   6.344 -    outw (val, addr+PCNET32_WIO_RDP);
   6.345 -}
   6.346 -
   6.347 -static u16 pcnet32_wio_read_bcr (unsigned long addr, int index)
   6.348 -{
   6.349 -    outw (index, addr+PCNET32_WIO_RAP);
   6.350 -    return inw (addr+PCNET32_WIO_BDP);
   6.351 -}
   6.352 -
   6.353 -static void pcnet32_wio_write_bcr (unsigned long addr, int index, u16 val)
   6.354 -{
   6.355 -    outw (index, addr+PCNET32_WIO_RAP);
   6.356 -    outw (val, addr+PCNET32_WIO_BDP);
   6.357 -}
   6.358 -
   6.359 -static u16 pcnet32_wio_read_rap (unsigned long addr)
   6.360 -{
   6.361 -    return inw (addr+PCNET32_WIO_RAP);
   6.362 -}
   6.363 -
   6.364 -static void pcnet32_wio_write_rap (unsigned long addr, u16 val)
   6.365 -{
   6.366 -    outw (val, addr+PCNET32_WIO_RAP);
   6.367 -}
   6.368 -
   6.369 -static void pcnet32_wio_reset (unsigned long addr)
   6.370 -{
   6.371 -    inw (addr+PCNET32_WIO_RESET);
   6.372 -}
   6.373 -
   6.374 -static int pcnet32_wio_check (unsigned long addr)
   6.375 -{
   6.376 -    outw (88, addr+PCNET32_WIO_RAP);
   6.377 -    return (inw (addr+PCNET32_WIO_RAP) == 88);
   6.378 -}
   6.379 -
   6.380 -static struct pcnet32_access pcnet32_wio = {
   6.381 -    pcnet32_wio_read_csr,
   6.382 -    pcnet32_wio_write_csr,
   6.383 -    pcnet32_wio_read_bcr,
   6.384 -    pcnet32_wio_write_bcr,
   6.385 -    pcnet32_wio_read_rap,
   6.386 -    pcnet32_wio_write_rap,
   6.387 -    pcnet32_wio_reset
   6.388 -};
   6.389 -
   6.390 -static u16 pcnet32_dwio_read_csr (unsigned long addr, int index)
   6.391 -{
   6.392 -    outl (index, addr+PCNET32_DWIO_RAP);
   6.393 -    return (inl (addr+PCNET32_DWIO_RDP) & 0xffff);
   6.394 -}
   6.395 -
   6.396 -static void pcnet32_dwio_write_csr (unsigned long addr, int index, u16 val)
   6.397 -{
   6.398 -    outl (index, addr+PCNET32_DWIO_RAP);
   6.399 -    outl (val, addr+PCNET32_DWIO_RDP);
   6.400 -}
   6.401 -
   6.402 -static u16 pcnet32_dwio_read_bcr (unsigned long addr, int index)
   6.403 -{
   6.404 -    outl (index, addr+PCNET32_DWIO_RAP);
   6.405 -    return (inl (addr+PCNET32_DWIO_BDP) & 0xffff);
   6.406 -}
   6.407 -
   6.408 -static void pcnet32_dwio_write_bcr (unsigned long addr, int index, u16 val)
   6.409 -{
   6.410 -    outl (index, addr+PCNET32_DWIO_RAP);
   6.411 -    outl (val, addr+PCNET32_DWIO_BDP);
   6.412 -}
   6.413 -
   6.414 -static u16 pcnet32_dwio_read_rap (unsigned long addr)
   6.415 -{
   6.416 -    return (inl (addr+PCNET32_DWIO_RAP) & 0xffff);
   6.417 -}
   6.418 -
   6.419 -static void pcnet32_dwio_write_rap (unsigned long addr, u16 val)
   6.420 -{
   6.421 -    outl (val, addr+PCNET32_DWIO_RAP);
   6.422 -}
   6.423 -
   6.424 -static void pcnet32_dwio_reset (unsigned long addr)
   6.425 -{
   6.426 -    inl (addr+PCNET32_DWIO_RESET);
   6.427 -}
   6.428 -
   6.429 -static int pcnet32_dwio_check (unsigned long addr)
   6.430 -{
   6.431 -    outl (88, addr+PCNET32_DWIO_RAP);
   6.432 -    return ((inl (addr+PCNET32_DWIO_RAP) & 0xffff) == 88);
   6.433 -}
   6.434 -
   6.435 -static struct pcnet32_access pcnet32_dwio = {
   6.436 -    pcnet32_dwio_read_csr,
   6.437 -    pcnet32_dwio_write_csr,
   6.438 -    pcnet32_dwio_read_bcr,
   6.439 -    pcnet32_dwio_write_bcr,
   6.440 -    pcnet32_dwio_read_rap,
   6.441 -    pcnet32_dwio_write_rap,
   6.442 -    pcnet32_dwio_reset
   6.443 -
   6.444 -};
   6.445 -
   6.446 -
   6.447 -
   6.448 -/* only probes for non-PCI devices, the rest are handled by pci_register_driver via pcnet32_probe_pci*/
   6.449 -static int __init pcnet32_probe_vlbus(int cards_found)
   6.450 -{
   6.451 -    unsigned long ioaddr = 0; // FIXME dev ? dev->base_addr: 0;
   6.452 -    unsigned int  irq_line = 0; // FIXME dev ? dev->irq : 0;
   6.453 -    int *port;
   6.454 -    
   6.455 -    printk(KERN_INFO "pcnet32_probe_vlbus: cards_found=%d\n", cards_found);
   6.456 -#ifndef __powerpc__
   6.457 -    if (ioaddr > 0x1ff) {
   6.458 -	if (check_region(ioaddr, PCNET32_TOTAL_SIZE) == 0)
   6.459 -	    return pcnet32_probe1(ioaddr, irq_line, 0, 0, NULL);
   6.460 -	else
   6.461 -	    return -ENODEV;
   6.462 -    } else
   6.463 -#endif
   6.464 -	if (ioaddr != 0)
   6.465 -	    return -ENXIO;
   6.466 -    
   6.467 -    /* now look for PCnet32 VLB cards */
   6.468 -    for (port = pcnet32_portlist; *port; port++) {
   6.469 -	unsigned long ioaddr = *port;
   6.470 -	
   6.471 -	if ( check_region(ioaddr, PCNET32_TOTAL_SIZE) == 0) {
   6.472 -	    /* check if there is really a pcnet chip on that ioaddr */
   6.473 -	    if ((inb(ioaddr + 14) == 0x57) &&
   6.474 -		(inb(ioaddr + 15) == 0x57) &&
   6.475 -		(pcnet32_probe1(ioaddr, 0, 0, 0, NULL) == 0))
   6.476 -		cards_found++;
   6.477 -	}
   6.478 -    }
   6.479 -    return cards_found ? 0: -ENODEV;
   6.480 -}
   6.481 -
   6.482 -
   6.483 -
   6.484 -static int __devinit
   6.485 -pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent)
   6.486 -{
   6.487 -    static int card_idx;
   6.488 -    long ioaddr;
   6.489 -    int err = 0;
   6.490 -
   6.491 -    printk(KERN_INFO "pcnet32_probe_pci: found device %#08x.%#08x\n", ent->vendor, ent->device);
   6.492 -
   6.493 -    if ((err = pci_enable_device(pdev)) < 0) {
   6.494 -	printk(KERN_ERR "pcnet32.c: failed to enable device -- err=%d\n", err);
   6.495 -	return err;
   6.496 -    }
   6.497 -    pci_set_master(pdev);
   6.498 -
   6.499 -    ioaddr = pci_resource_start (pdev, 0);
   6.500 -    printk(KERN_INFO "    ioaddr=%#08lx  resource_flags=%#08lx\n", ioaddr, pci_resource_flags (pdev, 0));
   6.501 -    if (!ioaddr) {
   6.502 -        printk (KERN_ERR "no PCI IO resources, aborting\n");
   6.503 -        return -ENODEV;
   6.504 -    }
   6.505 -	
   6.506 -    if (!pci_dma_supported(pdev, PCNET32_DMA_MASK)) {
   6.507 -	printk(KERN_ERR "pcnet32.c: architecture does not support 32bit PCI busmaster DMA\n");
   6.508 -	return -ENODEV;
   6.509 -    }
   6.510 -
   6.511 -    return pcnet32_probe1(ioaddr, pdev->irq, 1, card_idx, pdev);
   6.512 -}
   6.513 -
   6.514 -
   6.515 -/* pcnet32_probe1 
   6.516 - *  Called from both pcnet32_probe_vlbus and pcnet_probe_pci.  
   6.517 - *  pdev will be NULL when called from pcnet32_probe_vlbus.
   6.518 - */
   6.519 -static int __devinit
   6.520 -pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int card_idx, struct pci_dev *pdev)
   6.521 -{
   6.522 -    struct pcnet32_private *lp;
   6.523 -    struct resource *res;
   6.524 -    dma_addr_t lp_dma_addr;
   6.525 -    int i,media,fdx = 0, mii = 0, fset = 0;
   6.526 -#ifdef DO_DXSUFLO
   6.527 -    int dxsuflo = 0;
   6.528 -#endif
   6.529 -    int ltint = 0;
   6.530 -    int chip_version;
   6.531 -    char *chipname;
   6.532 -    struct net_device *dev;
   6.533 -    struct pcnet32_access *a = NULL;
   6.534 -
   6.535 -    /* reset the chip */
   6.536 -    pcnet32_dwio_reset(ioaddr);
   6.537 -    pcnet32_wio_reset(ioaddr);
   6.538 -
   6.539 -    /* NOTE: 16-bit check is first, otherwise some older PCnet chips fail */
   6.540 -    if (pcnet32_wio_read_csr (ioaddr, 0) == 4 && pcnet32_wio_check (ioaddr)) {
   6.541 -	a = &pcnet32_wio;
   6.542 -    } else {
   6.543 -	if (pcnet32_dwio_read_csr (ioaddr, 0) == 4 && pcnet32_dwio_check(ioaddr)) {
   6.544 -	    a = &pcnet32_dwio;
   6.545 -	} else
   6.546 -	    return -ENODEV;
   6.547 -    }
   6.548 -
   6.549 -    chip_version = a->read_csr (ioaddr, 88) | (a->read_csr (ioaddr,89) << 16);
   6.550 -    if (pcnet32_debug > 2)
   6.551 -	printk(KERN_INFO "  PCnet chip version is %#x.\n", chip_version);
   6.552 -    if ((chip_version & 0xfff) != 0x003)
   6.553 -	return -ENODEV;
   6.554 -    chip_version = (chip_version >> 12) & 0xffff;
   6.555 -    switch (chip_version) {
   6.556 -    case 0x2420:
   6.557 -	chipname = "PCnet/PCI 79C970"; /* PCI */
   6.558 -	break;
   6.559 -    case 0x2430:
   6.560 -	if (shared)
   6.561 -	    chipname = "PCnet/PCI 79C970"; /* 970 gives the wrong chip id back */
   6.562 -	else
   6.563 -	    chipname = "PCnet/32 79C965"; /* 486/VL bus */
   6.564 -	break;
   6.565 -    case 0x2621:
   6.566 -	chipname = "PCnet/PCI II 79C970A"; /* PCI */
   6.567 -	fdx = 1;
   6.568 -	break;
   6.569 -    case 0x2623:
   6.570 -	chipname = "PCnet/FAST 79C971"; /* PCI */
   6.571 -	fdx = 1; mii = 1; fset = 1;
   6.572 -	ltint = 1;
   6.573 -	break;
   6.574 -    case 0x2624:
   6.575 -	chipname = "PCnet/FAST+ 79C972"; /* PCI */
   6.576 -	fdx = 1; mii = 1; fset = 1;
   6.577 -	break;
   6.578 -    case 0x2625:
   6.579 -	chipname = "PCnet/FAST III 79C973"; /* PCI */
   6.580 -	fdx = 1; mii = 1;
   6.581 -	break;
   6.582 -    case 0x2626:
   6.583 -	chipname = "PCnet/Home 79C978"; /* PCI */
   6.584 -	fdx = 1;
   6.585 -	/* 
   6.586 -	 * This is based on specs published at www.amd.com.  This section
   6.587 -	 * assumes that a card with a 79C978 wants to go into 1Mb HomePNA
   6.588 -	 * mode.  The 79C978 can also go into standard ethernet, and there
   6.589 -	 * probably should be some sort of module option to select the
   6.590 -	 * mode by which the card should operate
   6.591 -	 */
   6.592 -	/* switch to home wiring mode */
   6.593 -	media = a->read_bcr (ioaddr, 49);
   6.594 -#if 0
   6.595 -	if (pcnet32_debug > 2)
   6.596 -	    printk(KERN_DEBUG "pcnet32: pcnet32 media value %#x.\n",  media);
   6.597 -	media &= ~3;
   6.598 -	media |= 1;
   6.599 -#endif
   6.600 -	if (pcnet32_debug > 2)
   6.601 -	    printk(KERN_DEBUG "pcnet32: pcnet32 media reset to %#x.\n",  media);
   6.602 -	a->write_bcr (ioaddr, 49, media);
   6.603 -	break;
   6.604 -    case 0x2627:
   6.605 -	chipname = "PCnet/FAST III 79C975"; /* PCI */
   6.606 -	fdx = 1; mii = 1;
   6.607 -	break;
   6.608 -    default:
   6.609 -	printk(KERN_INFO "pcnet32: PCnet version %#x, no PCnet32 chip.\n",chip_version);
   6.610 -	return -ENODEV;
   6.611 -    }
   6.612 -
   6.613 -    /*
   6.614 -     *	On selected chips turn on the BCR18:NOUFLO bit. This stops transmit
   6.615 -     *	starting until the packet is loaded. Strike one for reliability, lose
   6.616 -     *	one for latency - although on PCI this isnt a big loss. Older chips 
   6.617 -     *	have FIFO's smaller than a packet, so you can't do this.
   6.618 -     */
   6.619 -	 
   6.620 -    if(fset)
   6.621 -    {
   6.622 -	a->write_bcr(ioaddr, 18, (a->read_bcr(ioaddr, 18) | 0x0800));
   6.623 -	a->write_csr(ioaddr, 80, (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00);
   6.624 -#ifdef DO_DXSUFLO
   6.625 -	dxsuflo = 1;
   6.626 -#endif
   6.627 -	ltint = 1;
   6.628 -    }
   6.629 -    
   6.630 -    dev = init_etherdev(NULL, 0);
   6.631 -    if(dev==NULL)
   6.632 -	return -ENOMEM;
   6.633 -
   6.634 -    printk(KERN_INFO "%s: %s at %#3lx,", dev->name, chipname, ioaddr);
   6.635 -
   6.636 -    /* In most chips, after a chip reset, the ethernet address is read from the
   6.637 -     * station address PROM at the base address and programmed into the
   6.638 -     * "Physical Address Registers" CSR12-14.
   6.639 -     * As a precautionary measure, we read the PROM values and complain if
   6.640 -     * they disagree with the CSRs.  Either way, we use the CSR values, and
   6.641 -     * double check that they are valid.
   6.642 -     */
   6.643 -    for (i = 0; i < 3; i++) {
   6.644 -	unsigned int val;
   6.645 -	val = a->read_csr(ioaddr, i+12) & 0x0ffff;
   6.646 -	/* There may be endianness issues here. */
   6.647 -	dev->dev_addr[2*i] = val & 0x0ff;
   6.648 -	dev->dev_addr[2*i+1] = (val >> 8) & 0x0ff;
   6.649 -    }
   6.650 -    {
   6.651 -	u8 promaddr[6];
   6.652 -	for (i = 0; i < 6; i++) {
   6.653 -	    promaddr[i] = inb(ioaddr + i);
   6.654 -	}
   6.655 -	if( memcmp( promaddr, dev->dev_addr, 6) )
   6.656 -	{
   6.657 -	    printk(" warning PROM address does not match CSR address\n");
   6.658 -#if defined(__i386__)
   6.659 -	    printk(KERN_WARNING "%s: Probably a Compaq, using the PROM address of", dev->name);
   6.660 -	    memcpy(dev->dev_addr, promaddr, 6);
   6.661 -#endif
   6.662 -	}	    	    
   6.663 -    }
   6.664 -    /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */
   6.665 -    if( !is_valid_ether_addr(dev->dev_addr) )
   6.666 -	for (i = 0; i < 6; i++)
   6.667 -	    dev->dev_addr[i]=0;
   6.668 -
   6.669 -    for (i = 0; i < 6; i++)
   6.670 -	printk(" %2.2x", dev->dev_addr[i] );
   6.671 -
   6.672 -    if (((chip_version + 1) & 0xfffe) == 0x2624) { /* Version 0x2623 or 0x2624 */
   6.673 -	i = a->read_csr(ioaddr, 80) & 0x0C00;  /* Check tx_start_pt */
   6.674 -	printk("\n" KERN_INFO "    tx_start_pt(0x%04x):",i);
   6.675 -	switch(i>>10) {
   6.676 -	    case 0: printk("  20 bytes,"); break;
   6.677 -	    case 1: printk("  64 bytes,"); break;
   6.678 -	    case 2: printk(" 128 bytes,"); break;
   6.679 -	    case 3: printk("~220 bytes,"); break;
   6.680 -	}
   6.681 -	i = a->read_bcr(ioaddr, 18);  /* Check Burst/Bus control */
   6.682 -	printk(" BCR18(%x):",i&0xffff);
   6.683 -	if (i & (1<<5)) printk("BurstWrEn ");
   6.684 -	if (i & (1<<6)) printk("BurstRdEn ");
   6.685 -	if (i & (1<<7)) printk("DWordIO ");
   6.686 -	if (i & (1<<11)) printk("NoUFlow ");
   6.687 -	i = a->read_bcr(ioaddr, 25);
   6.688 -	printk("\n" KERN_INFO "    SRAMSIZE=0x%04x,",i<<8);
   6.689 -	i = a->read_bcr(ioaddr, 26);
   6.690 -	printk(" SRAM_BND=0x%04x,",i<<8);
   6.691 -	i = a->read_bcr(ioaddr, 27);
   6.692 -	if (i & (1<<14)) printk("LowLatRx");
   6.693 -    }
   6.694 -
   6.695 -    dev->base_addr = ioaddr;
   6.696 -    res = request_region(ioaddr, PCNET32_TOTAL_SIZE, chipname);
   6.697 -    if (res == NULL)
   6.698 -	return -EBUSY;
   6.699 -    
   6.700 -    /* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */
   6.701 -    if ((lp = pci_alloc_consistent(pdev, sizeof(*lp), &lp_dma_addr)) == NULL) {
   6.702 -	release_resource(res);
   6.703 -	return -ENOMEM;
   6.704 -    }
   6.705 -
   6.706 -    memset(lp, 0, sizeof(*lp));
   6.707 -    lp->dma_addr = lp_dma_addr;
   6.708 -    lp->pci_dev = pdev;
   6.709 -    printk("\n" KERN_INFO "pcnet32: pcnet32_private lp=%p lp_dma_addr=%#08x", lp, lp_dma_addr);
   6.710 -
   6.711 -    spin_lock_init(&lp->lock);
   6.712 -    
   6.713 -    dev->priv = lp;
   6.714 -    lp->name = chipname;
   6.715 -    lp->shared_irq = shared;
   6.716 -    lp->full_duplex = fdx;
   6.717 -#ifdef DO_DXSUFLO
   6.718 -    lp->dxsuflo = dxsuflo;
   6.719 -#endif
   6.720 -    lp->ltint = ltint;
   6.721 -    lp->mii = mii;
   6.722 -    if (options[card_idx] > sizeof (options_mapping))
   6.723 -	lp->options = PORT_ASEL;
   6.724 -    else
   6.725 -	lp->options = options_mapping[options[card_idx]];
   6.726 -    
   6.727 -    if (fdx && !(lp->options & PORT_ASEL) && full_duplex[card_idx])
   6.728 -	lp->options |= PORT_FD;
   6.729 -    
   6.730 -    if (a == NULL) {
   6.731 -      printk(KERN_ERR "pcnet32: No access methods\n");
   6.732 -      pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
   6.733 -      release_resource(res);
   6.734 -      return -ENODEV;
   6.735 -    }
   6.736 -    lp->a = *a;
   6.737 -    
   6.738 -    /* detect special T1/E1 WAN card by checking for MAC address */
   6.739 -    if (dev->dev_addr[0] == 0x00 && dev->dev_addr[1] == 0xe0 && dev->dev_addr[2] == 0x75)
   6.740 -	lp->options = PORT_FD | PORT_GPSI;
   6.741 -
   6.742 -    lp->init_block.mode = le16_to_cpu(0x0003);	/* Disable Rx and Tx. */
   6.743 -    lp->init_block.tlen_rlen = le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS); 
   6.744 -    for (i = 0; i < 6; i++)
   6.745 -	lp->init_block.phys_addr[i] = dev->dev_addr[i];
   6.746 -    lp->init_block.filter[0] = 0x00000000;
   6.747 -    lp->init_block.filter[1] = 0x00000000;
   6.748 -    lp->init_block.rx_ring = (u32)le32_to_cpu(lp->dma_addr + offsetof(struct pcnet32_private, rx_ring));
   6.749 -    lp->init_block.tx_ring = (u32)le32_to_cpu(lp->dma_addr + offsetof(struct pcnet32_private, tx_ring));
   6.750 -    
   6.751 -    /* switch pcnet32 to 32bit mode */
   6.752 -    a->write_bcr (ioaddr, 20, 2);
   6.753 -
   6.754 -    a->write_csr (ioaddr, 1, (lp->dma_addr + offsetof(struct pcnet32_private, init_block)) & 0xffff);
   6.755 -    a->write_csr (ioaddr, 2, (lp->dma_addr + offsetof(struct pcnet32_private, init_block)) >> 16);
   6.756 -    
   6.757 -    if (irq_line) {
   6.758 -	dev->irq = irq_line;
   6.759 -    }
   6.760 -    
   6.761 -    if (dev->irq >= 2)
   6.762 -	printk(" assigned IRQ %d.\n", dev->irq);
   6.763 -    else {
   6.764 -	unsigned long irq_mask = probe_irq_on();
   6.765 -	
   6.766 -	/*
   6.767 -	 * To auto-IRQ we enable the initialization-done and DMA error
   6.768 -	 * interrupts. For ISA boards we get a DMA error, but VLB and PCI
   6.769 -	 * boards will work.
   6.770 -	 */
   6.771 -	/* Trigger an initialization just for the interrupt. */
   6.772 -	a->write_csr (ioaddr, 0, 0x41);
   6.773 -	mdelay (1);
   6.774 -	
   6.775 -	dev->irq = probe_irq_off (irq_mask);
   6.776 -	if (dev->irq)
   6.777 -	    printk(", probed IRQ %d.\n", dev->irq);
   6.778 -	else {
   6.779 -	    printk(", failed to detect IRQ line.\n");
   6.780 -	    pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
   6.781 -	    release_resource(res);
   6.782 -	    return -ENODEV;
   6.783 -	}
   6.784 -    }
   6.785 -
   6.786 -    if (pcnet32_debug > 0)
   6.787 -	printk(KERN_INFO "%s", version);
   6.788 -    
   6.789 -    /* The PCNET32-specific entries in the device structure. */
   6.790 -    dev->open = &pcnet32_open;
   6.791 -    dev->hard_start_xmit = &pcnet32_start_xmit;
   6.792 -    dev->stop = &pcnet32_close;
   6.793 -    dev->get_stats = &pcnet32_get_stats;
   6.794 -    dev->set_multicast_list = &pcnet32_set_multicast_list;
   6.795 -#ifdef HAVE_PRIVATE_IOCTL
   6.796 -    dev->do_ioctl = &pcnet32_mii_ioctl;
   6.797 -#endif
   6.798 -    dev->tx_timeout = pcnet32_tx_timeout;
   6.799 -    dev->watchdog_timeo = (HZ >> 1);
   6.800 -
   6.801 -    lp->next = pcnet32_dev;
   6.802 -    pcnet32_dev = dev;
   6.803 -
   6.804 -    /* Fill in the generic fields of the device structure. */
   6.805 -    ether_setup(dev);
   6.806 -    return 0;
   6.807 -}
   6.808 -
   6.809 -
   6.810 -static int
   6.811 -pcnet32_open(struct net_device *dev)
   6.812 -{
   6.813 -    struct pcnet32_private *lp = dev->priv;
   6.814 -    unsigned long ioaddr = dev->base_addr;
   6.815 -    u16 val;
   6.816 -    int i;
   6.817 -
   6.818 -    if (dev->irq == 0 ||
   6.819 -	request_irq(dev->irq, &pcnet32_interrupt,
   6.820 -		    lp->shared_irq ? SA_SHIRQ : 0, lp->name, (void *)dev)) {
   6.821 -	return -EAGAIN;
   6.822 -    }
   6.823 -
   6.824 -    /* Check for a valid station address */
   6.825 -    if( !is_valid_ether_addr(dev->dev_addr) )
   6.826 -	return -EINVAL;
   6.827 -
   6.828 -    /* Reset the PCNET32 */
   6.829 -    lp->a.reset (ioaddr);
   6.830 -
   6.831 -    /* switch pcnet32 to 32bit mode */
   6.832 -    lp->a.write_bcr (ioaddr, 20, 2);
   6.833 -
   6.834 -    if (pcnet32_debug > 1)
   6.835 -	printk(KERN_DEBUG "%s: pcnet32_open() irq %d tx/rx rings %#x/%#x init %#x.\n",
   6.836 -	       dev->name, dev->irq,
   6.837 -	       (u32) (lp->dma_addr + offsetof(struct pcnet32_private, tx_ring)),
   6.838 -	       (u32) (lp->dma_addr + offsetof(struct pcnet32_private, rx_ring)),
   6.839 -	       (u32) (lp->dma_addr + offsetof(struct pcnet32_private, init_block)));
   6.840 -    
   6.841 -    /* set/reset autoselect bit */
   6.842 -    val = lp->a.read_bcr (ioaddr, 2) & ~2;
   6.843 -    if (lp->options & PORT_ASEL)
   6.844 -	val |= 2;
   6.845 -    lp->a.write_bcr (ioaddr, 2, val);
   6.846 -    
   6.847 -    /* handle full duplex setting */
   6.848 -    if (lp->full_duplex) {
   6.849 -	val = lp->a.read_bcr (ioaddr, 9) & ~3;
   6.850 -	if (lp->options & PORT_FD) {
   6.851 -	    val |= 1;
   6.852 -	    if (lp->options == (PORT_FD | PORT_AUI))
   6.853 -		val |= 2;
   6.854 -	}
   6.855 -	lp->a.write_bcr (ioaddr, 9, val);
   6.856 -    }
   6.857 -    
   6.858 -    /* set/reset GPSI bit in test register */
   6.859 -    val = lp->a.read_csr (ioaddr, 124) & ~0x10;
   6.860 -    if ((lp->options & PORT_PORTSEL) == PORT_GPSI)
   6.861 -	val |= 0x10;
   6.862 -    lp->a.write_csr (ioaddr, 124, val);
   6.863 -    
   6.864 -    if (lp->mii && !(lp->options & PORT_ASEL)) {
   6.865 -	val = lp->a.read_bcr (ioaddr, 32) & ~0x38; /* disable Auto Negotiation, set 10Mpbs, HD */
   6.866 -	if (lp->options & PORT_FD)
   6.867 -	    val |= 0x10;
   6.868 -	if (lp->options & PORT_100)
   6.869 -	    val |= 0x08;
   6.870 -	lp->a.write_bcr (ioaddr, 32, val);
   6.871 -    } else {
   6.872 -	if (lp->options & PORT_ASEL) {  /* enable auto negotiate, setup, disable fd */
   6.873 -		val = lp->a.read_bcr(ioaddr, 32) & ~0x98;
   6.874 -		val |= 0x20;
   6.875 -		lp->a.write_bcr(ioaddr, 32, val);
   6.876 -	}
   6.877 -    }
   6.878 -
   6.879 -#ifdef DO_DXSUFLO 
   6.880 -    if (lp->dxsuflo) { /* Disable transmit stop on underflow */
   6.881 -	val = lp->a.read_csr (ioaddr, 3);
   6.882 -	val |= 0x40;
   6.883 -	lp->a.write_csr (ioaddr, 3, val);
   6.884 -    }
   6.885 -#endif
   6.886 -    if (lp->ltint) { /* Enable TxDone-intr inhibitor */
   6.887 -	val = lp->a.read_csr (ioaddr, 5);
   6.888 -	val |= (1<<14);
   6.889 -	lp->a.write_csr (ioaddr, 5, val);
   6.890 -    }
   6.891 -   
   6.892 -    lp->init_block.mode = le16_to_cpu((lp->options & PORT_PORTSEL) << 7);
   6.893 -    lp->init_block.filter[0] = 0x00000000;
   6.894 -    lp->init_block.filter[1] = 0x00000000;
   6.895 -    if (pcnet32_init_ring(dev))
   6.896 -	return -ENOMEM;
   6.897 -    
   6.898 -    /* Re-initialize the PCNET32, and start it when done. */
   6.899 -    lp->a.write_csr (ioaddr, 1, (lp->dma_addr + offsetof(struct pcnet32_private, init_block)) &0xffff);
   6.900 -    lp->a.write_csr (ioaddr, 2, (lp->dma_addr + offsetof(struct pcnet32_private, init_block)) >> 16);
   6.901 -
   6.902 -    lp->a.write_csr (ioaddr, 4, 0x0915);
   6.903 -    lp->a.write_csr (ioaddr, 0, 0x0001);
   6.904 -
   6.905 -    netif_start_queue(dev);
   6.906 -
   6.907 -    i = 0;
   6.908 -    while (i++ < 100)
   6.909 -	if (lp->a.read_csr (ioaddr, 0) & 0x0100)
   6.910 -	    break;
   6.911 -    /* 
   6.912 -     * We used to clear the InitDone bit, 0x0100, here but Mark Stockton
   6.913 -     * reports that doing so triggers a bug in the '974.
   6.914 -     */
   6.915 -    lp->a.write_csr (ioaddr, 0, 0x0042);
   6.916 -
   6.917 -    if (pcnet32_debug > 2)
   6.918 -	printk(KERN_DEBUG "%s: pcnet32 open after %d ticks, init block %#x csr0 %4.4x.\n",
   6.919 -	       dev->name, i, (u32) (lp->dma_addr + offsetof(struct pcnet32_private, init_block)),
   6.920 -	       lp->a.read_csr (ioaddr, 0));
   6.921 -
   6.922 -
   6.923 -    MOD_INC_USE_COUNT;
   6.924 -    
   6.925 -    return 0;	/* Always succeed */
   6.926 -}
   6.927 -
   6.928 -/*
   6.929 - * The LANCE has been halted for one reason or another (busmaster memory
   6.930 - * arbitration error, Tx FIFO underflow, driver stopped it to reconfigure,
   6.931 - * etc.).  Modern LANCE variants always reload their ring-buffer
   6.932 - * configuration when restarted, so we must reinitialize our ring
   6.933 - * context before restarting.  As part of this reinitialization,
   6.934 - * find all packets still on the Tx ring and pretend that they had been
   6.935 - * sent (in effect, drop the packets on the floor) - the higher-level
   6.936 - * protocols will time out and retransmit.  It'd be better to shuffle
   6.937 - * these skbs to a temp list and then actually re-Tx them after
   6.938 - * restarting the chip, but I'm too lazy to do so right now.  dplatt@3do.com
   6.939 - */
   6.940 -
   6.941 -static void 
   6.942 -pcnet32_purge_tx_ring(struct net_device *dev)
   6.943 -{
   6.944 -    struct pcnet32_private *lp = dev->priv;
   6.945 -    int i;
   6.946 -
   6.947 -    for (i = 0; i < TX_RING_SIZE; i++) {
   6.948 -	if (lp->tx_skbuff[i]) {
   6.949 -            pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[i], lp->tx_skbuff[i]->len, PCI_DMA_TODEVICE);
   6.950 -	    dev_kfree_skb(lp->tx_skbuff[i]); 
   6.951 -	    lp->tx_skbuff[i] = NULL;
   6.952 -            lp->tx_dma_addr[i] = 0;
   6.953 -	}
   6.954 -    }
   6.955 -}
   6.956 -
   6.957 -
   6.958 -/* Initialize the PCNET32 Rx and Tx rings. */
   6.959 -static int
   6.960 -pcnet32_init_ring(struct net_device *dev)
   6.961 -{
   6.962 -    struct pcnet32_private *lp = dev->priv;
   6.963 -    int i;
   6.964 -
   6.965 -    lp->tx_full = 0;
   6.966 -    lp->cur_rx = lp->cur_tx = 0;
   6.967 -    lp->dirty_rx = lp->dirty_tx = 0;
   6.968 -
   6.969 -    for (i = 0; i < RX_RING_SIZE; i++) {
   6.970 -        struct sk_buff *rx_skbuff = lp->rx_skbuff[i];
   6.971 -	if (rx_skbuff == NULL) {
   6.972 -	    if (!(rx_skbuff = lp->rx_skbuff[i] = dev_alloc_skb (PKT_BUF_SZ))) {
   6.973 -		/* there is not much, we can do at this point */
   6.974 -		printk(KERN_ERR "%s: pcnet32_init_ring dev_alloc_skb failed.\n",dev->name);
   6.975 -		return -1;
   6.976 -	    }
   6.977 -	    skb_reserve (rx_skbuff, 2);
   6.978 -	}
   6.979 -        lp->rx_dma_addr[i] = pci_map_single(lp->pci_dev, rx_skbuff->tail, rx_skbuff->len, PCI_DMA_FROMDEVICE);
   6.980 -	lp->rx_ring[i].base = (u32)le32_to_cpu(lp->rx_dma_addr[i]);
   6.981 -	lp->rx_ring[i].buf_length = le16_to_cpu(-PKT_BUF_SZ);
   6.982 -	lp->rx_ring[i].status = le16_to_cpu(0x8000);
   6.983 -    }
   6.984 -    /* The Tx buffer address is filled in as needed, but we do need to clear
   6.985 -       the upper ownership bit. */
   6.986 -    for (i = 0; i < TX_RING_SIZE; i++) {
   6.987 -	lp->tx_ring[i].base = 0;
   6.988 -	lp->tx_ring[i].status = 0;
   6.989 -        lp->tx_dma_addr[i] = 0;
   6.990 -    }
   6.991 -
   6.992 -    lp->init_block.tlen_rlen = le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS);
   6.993 -    for (i = 0; i < 6; i++)
   6.994 -	lp->init_block.phys_addr[i] = dev->dev_addr[i];
   6.995 -    lp->init_block.rx_ring = (u32)le32_to_cpu(lp->dma_addr + offsetof(struct pcnet32_private, rx_ring));
   6.996 -    lp->init_block.tx_ring = (u32)le32_to_cpu(lp->dma_addr + offsetof(struct pcnet32_private, tx_ring));
   6.997 -    return 0;
   6.998 -}
   6.999 -
  6.1000 -static void
  6.1001 -pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
  6.1002 -{
  6.1003 -    struct pcnet32_private *lp = dev->priv;
  6.1004 -    unsigned long ioaddr = dev->base_addr;
  6.1005 -    int i;
  6.1006 -    
  6.1007 -    pcnet32_purge_tx_ring(dev);
  6.1008 -    if (pcnet32_init_ring(dev))
  6.1009 -	return;
  6.1010 -    
  6.1011 -    /* ReInit Ring */
  6.1012 -    lp->a.write_csr (ioaddr, 0, 1);
  6.1013 -    i = 0;
  6.1014 -    while (i++ < 100)
  6.1015 -	if (lp->a.read_csr (ioaddr, 0) & 0x0100)
  6.1016 -	    break;
  6.1017 -
  6.1018 -    lp->a.write_csr (ioaddr, 0, csr0_bits);
  6.1019 -}
  6.1020 -
  6.1021 -
  6.1022 -static void
  6.1023 -pcnet32_tx_timeout (struct net_device *dev)
  6.1024 -{
  6.1025 -    struct pcnet32_private *lp = dev->priv;
  6.1026 -    unsigned int ioaddr = dev->base_addr;
  6.1027 -
  6.1028 -    /* Transmitter timeout, serious problems. */
  6.1029 -	printk(KERN_ERR "%s: transmit timed out, status %4.4x, resetting.\n",
  6.1030 -	       dev->name, lp->a.read_csr (ioaddr, 0));
  6.1031 -	lp->a.write_csr (ioaddr, 0, 0x0004);
  6.1032 -	lp->stats.tx_errors++;
  6.1033 -	if (pcnet32_debug > 2) {
  6.1034 -	    int i;
  6.1035 -	    printk(KERN_DEBUG " Ring data dump: dirty_tx %d cur_tx %d%s cur_rx %d.",
  6.1036 -	       lp->dirty_tx, lp->cur_tx, lp->tx_full ? " (full)" : "",
  6.1037 -	       lp->cur_rx);
  6.1038 -	    for (i = 0 ; i < RX_RING_SIZE; i++)
  6.1039 -	    printk("%s %08x %04x %08x %04x", i & 1 ? "" : "\n ",
  6.1040 -		   lp->rx_ring[i].base, -lp->rx_ring[i].buf_length,
  6.1041 -		   lp->rx_ring[i].msg_length, (unsigned)lp->rx_ring[i].status);
  6.1042 -	    for (i = 0 ; i < TX_RING_SIZE; i++)
  6.1043 -	    printk("%s %08x %04x %08x %04x", i & 1 ? "" : "\n ",
  6.1044 -		   lp->tx_ring[i].base, -lp->tx_ring[i].length,
  6.1045 -		   lp->tx_ring[i].misc, (unsigned)lp->tx_ring[i].status);
  6.1046 -	    printk("\n");
  6.1047 -	}
  6.1048 -	pcnet32_restart(dev, 0x0042);
  6.1049 -
  6.1050 -	dev->trans_start = jiffies;
  6.1051 -	netif_start_queue(dev);
  6.1052 -}
  6.1053 -
  6.1054 -
  6.1055 -static int
  6.1056 -pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
  6.1057 -{
  6.1058 -    struct pcnet32_private *lp = dev->priv;
  6.1059 -    unsigned int ioaddr = dev->base_addr;
  6.1060 -    u16 status;
  6.1061 -    int entry;
  6.1062 -    unsigned long flags;
  6.1063 -
  6.1064 -    if (pcnet32_debug > 3) {
  6.1065 -	printk(KERN_DEBUG "%s: pcnet32_start_xmit() called, csr0 %4.4x.\n",
  6.1066 -	       dev->name, lp->a.read_csr (ioaddr, 0));
  6.1067 -    }
  6.1068 -
  6.1069 -    spin_lock_irqsave(&lp->lock, flags);
  6.1070 -
  6.1071 -    /* Default status -- will not enable Successful-TxDone
  6.1072 -     * interrupt when that option is available to us.
  6.1073 -     */
  6.1074 -    status = 0x8300;
  6.1075 -    if ((lp->ltint) &&
  6.1076 -	((lp->cur_tx - lp->dirty_tx == TX_RING_SIZE/2) ||
  6.1077 -	 (lp->cur_tx - lp->dirty_tx >= TX_RING_SIZE-2)))
  6.1078 -    {
  6.1079 -	/* Enable Successful-TxDone interrupt if we have
  6.1080 -	 * 1/2 of, or nearly all of, our ring buffer Tx'd
  6.1081 -	 * but not yet cleaned up.  Thus, most of the time,
  6.1082 -	 * we will not enable Successful-TxDone interrupts.
  6.1083 -	 */
  6.1084 -	status = 0x9300;
  6.1085 -    }
  6.1086 -  
  6.1087 -    /* Fill in a Tx ring entry */
  6.1088 -  
  6.1089 -    /* Mask to ring buffer boundary. */
  6.1090 -    entry = lp->cur_tx & TX_RING_MOD_MASK;
  6.1091 -  
  6.1092 -    /* Caution: the write order is important here, set the base address
  6.1093 -       with the "ownership" bits last. */
  6.1094 -
  6.1095 -    lp->tx_ring[entry].length = le16_to_cpu(-skb->len);
  6.1096 -
  6.1097 -    lp->tx_ring[entry].misc = 0x00000000;
  6.1098 -
  6.1099 -    lp->tx_skbuff[entry] = skb;
  6.1100 -    lp->tx_dma_addr[entry] = pci_map_single(lp->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE);
  6.1101 -    lp->tx_ring[entry].base = (u32)le32_to_cpu(lp->tx_dma_addr[entry]);
  6.1102 -    lp->tx_ring[entry].status = le16_to_cpu(status);
  6.1103 -
  6.1104 -    lp->cur_tx++;
  6.1105 -    lp->stats.tx_bytes += skb->len;
  6.1106 -
  6.1107 -    /* Trigger an immediate send poll. */
  6.1108 -    lp->a.write_csr (ioaddr, 0, 0x0048);
  6.1109 -
  6.1110 -    dev->trans_start = jiffies;
  6.1111 -
  6.1112 -    if (lp->tx_ring[(entry+1) & TX_RING_MOD_MASK].base == 0)
  6.1113 -	netif_start_queue(dev);
  6.1114 -    else {
  6.1115 -	lp->tx_full = 1;
  6.1116 -	netif_stop_queue(dev);
  6.1117 -    }
  6.1118 -    spin_unlock_irqrestore(&lp->lock, flags);
  6.1119 -    return 0;
  6.1120 -}
  6.1121 -
  6.1122 -/* The PCNET32 interrupt handler. */
  6.1123 -static void
  6.1124 -pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
  6.1125 -{
  6.1126 -    struct net_device *dev = dev_id;
  6.1127 -    struct pcnet32_private *lp;
  6.1128 -    unsigned long ioaddr;
  6.1129 -    u16 csr0,rap;
  6.1130 -    int boguscnt =  max_interrupt_work;
  6.1131 -    int must_restart;
  6.1132 -
  6.1133 -    if (dev == NULL) {
  6.1134 -	printk (KERN_DEBUG "pcnet32_interrupt(): irq %d for unknown device.\n", irq);
  6.1135 -	return;
  6.1136 -    }
  6.1137 -
  6.1138 -    ioaddr = dev->base_addr;
  6.1139 -    lp = dev->priv;
  6.1140 -    
  6.1141 -    spin_lock(&lp->lock);
  6.1142 -    
  6.1143 -    rap = lp->a.read_rap(ioaddr);
  6.1144 -    while ((csr0 = lp->a.read_csr (ioaddr, 0)) & 0x8600 && --boguscnt >= 0) {
  6.1145 -	/* Acknowledge all of the current interrupt sources ASAP. */
  6.1146 -	lp->a.write_csr (ioaddr, 0, csr0 & ~0x004f);
  6.1147 -
  6.1148 -	must_restart = 0;
  6.1149 -
  6.1150 -	if (pcnet32_debug > 5)
  6.1151 -	    printk(KERN_DEBUG "%s: interrupt  csr0=%#2.2x new csr=%#2.2x.\n",
  6.1152 -		   dev->name, csr0, lp->a.read_csr (ioaddr, 0));
  6.1153 -
  6.1154 -	if (csr0 & 0x0400)		/* Rx interrupt */
  6.1155 -	    pcnet32_rx(dev);
  6.1156 -
  6.1157 -	if (csr0 & 0x0200) {		/* Tx-done interrupt */
  6.1158 -	    unsigned int dirty_tx = lp->dirty_tx;
  6.1159 -
  6.1160 -	    while (dirty_tx < lp->cur_tx) {
  6.1161 -		int entry = dirty_tx & TX_RING_MOD_MASK;
  6.1162 -		int status = (short)le16_to_cpu(lp->tx_ring[entry].status);
  6.1163 -			
  6.1164 -		if (status < 0)
  6.1165 -		    break;		/* It still hasn't been Txed */
  6.1166 -
  6.1167 -		lp->tx_ring[entry].base = 0;
  6.1168 -
  6.1169 -		if (status & 0x4000) {
  6.1170 -		    /* There was an major error, log it. */
  6.1171 -		    int err_status = le32_to_cpu(lp->tx_ring[entry].misc);
  6.1172 -		    lp->stats.tx_errors++;
  6.1173 -		    if (err_status & 0x04000000) lp->stats.tx_aborted_errors++;
  6.1174 -		    if (err_status & 0x08000000) lp->stats.tx_carrier_errors++;
  6.1175 -		    if (err_status & 0x10000000) lp->stats.tx_window_errors++;
  6.1176 -#ifndef DO_DXSUFLO
  6.1177 -		    if (err_status & 0x40000000) {
  6.1178 -			lp->stats.tx_fifo_errors++;
  6.1179 -			/* Ackk!  On FIFO errors the Tx unit is turned off! */
  6.1180 -			/* Remove this verbosity later! */
  6.1181 -			printk(KERN_ERR "%s: Tx FIFO error! CSR0=%4.4x\n",
  6.1182 -			       dev->name, csr0);
  6.1183 -			must_restart = 1;
  6.1184 -		    }
  6.1185 -#else
  6.1186 -		    if (err_status & 0x40000000) {
  6.1187 -			lp->stats.tx_fifo_errors++;
  6.1188 -			if (! lp->dxsuflo) {  /* If controller doesn't recover ... */
  6.1189 -			    /* Ackk!  On FIFO errors the Tx unit is turned off! */
  6.1190 -			    /* Remove this verbosity later! */
  6.1191 -			    printk(KERN_ERR "%s: Tx FIFO error! CSR0=%4.4x\n",
  6.1192 -				   dev->name, csr0);
  6.1193 -			    must_restart = 1;
  6.1194 -			}
  6.1195 -		    }
  6.1196 -#endif
  6.1197 -		} else {
  6.1198 -		    if (status & 0x1800)
  6.1199 -			lp->stats.collisions++;
  6.1200 -		    lp->stats.tx_packets++;
  6.1201 -		}
  6.1202 -
  6.1203 -		/* We must free the original skb */
  6.1204 -		if (lp->tx_skbuff[entry]) {
  6.1205 -                    pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[entry], lp->tx_skbuff[entry]->len, PCI_DMA_TODEVICE);
  6.1206 -		    dev_kfree_skb_irq(lp->tx_skbuff[entry]);
  6.1207 -		    lp->tx_skbuff[entry] = 0;
  6.1208 -                    lp->tx_dma_addr[entry] = 0;
  6.1209 -		}
  6.1210 -		dirty_tx++;
  6.1211 -	    }
  6.1212 -
  6.1213 -#ifndef final_version
  6.1214 -	    if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) {
  6.1215 -		printk(KERN_ERR "out-of-sync dirty pointer, %d vs. %d, full=%d.\n",
  6.1216 -		       dirty_tx, lp->cur_tx, lp->tx_full);
  6.1217 -		dirty_tx += TX_RING_SIZE;
  6.1218 -	    }
  6.1219 -#endif
  6.1220 -	    if (lp->tx_full &&
  6.1221 -		netif_queue_stopped(dev) &&
  6.1222 -		dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
  6.1223 -		/* The ring is no longer full, clear tbusy. */
  6.1224 -		lp->tx_full = 0;
  6.1225 -		netif_wake_queue (dev);
  6.1226 -	    }
  6.1227 -	    lp->dirty_tx = dirty_tx;
  6.1228 -	}
  6.1229 -
  6.1230 -	/* Log misc errors. */
  6.1231 -	if (csr0 & 0x4000) lp->stats.tx_errors++; /* Tx babble. */
  6.1232 -	if (csr0 & 0x1000) {
  6.1233 -	    /*
  6.1234 -	     * this happens when our receive ring is full. This shouldn't
  6.1235 -	     * be a problem as we will see normal rx interrupts for the frames
  6.1236 -	     * in the receive ring. But there are some PCI chipsets (I can reproduce
  6.1237 -	     * this on SP3G with Intel saturn chipset) which have sometimes problems
  6.1238 -	     * and will fill up the receive ring with error descriptors. In this
  6.1239 -	     * situation we don't get a rx interrupt, but a missed frame interrupt sooner
  6.1240 -	     * or later. So we try to clean up our receive ring here.
  6.1241 -	     */
  6.1242 -	    pcnet32_rx(dev);
  6.1243 -	    lp->stats.rx_errors++; /* Missed a Rx frame. */
  6.1244 -	}
  6.1245 -	if (csr0 & 0x0800) {
  6.1246 -	    printk(KERN_ERR "%s: Bus master arbitration failure, status %4.4x.\n",
  6.1247 -		   dev->name, csr0);
  6.1248 -	    /* unlike for the lance, there is no restart needed */
  6.1249 -	}
  6.1250 -
  6.1251 -	if (must_restart) {
  6.1252 -	    /* stop the chip to clear the error condition, then restart */
  6.1253 -	    lp->a.write_csr (ioaddr, 0, 0x0004);
  6.1254 -	    pcnet32_restart(dev, 0x0002);
  6.1255 -	}
  6.1256 -    }
  6.1257 -
  6.1258 -    /* Clear any other interrupt, and set interrupt enable. */
  6.1259 -    lp->a.write_csr (ioaddr, 0, 0x7940);
  6.1260 -    lp->a.write_rap(ioaddr,rap);
  6.1261 -    
  6.1262 -    if (pcnet32_debug > 4)
  6.1263 -	printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n",
  6.1264 -	       dev->name, lp->a.read_csr (ioaddr, 0));
  6.1265 -
  6.1266 -    spin_unlock(&lp->lock);
  6.1267 -}
  6.1268 -
  6.1269 -static int
  6.1270 -pcnet32_rx(struct net_device *dev)
  6.1271 -{
  6.1272 -    struct pcnet32_private *lp = dev->priv;
  6.1273 -    int entry = lp->cur_rx & RX_RING_MOD_MASK;
  6.1274 -
  6.1275 -    /* If we own the next entry, it's a new packet. Send it up. */
  6.1276 -    while ((short)le16_to_cpu(lp->rx_ring[entry].status) >= 0) {
  6.1277 -	int status = (short)le16_to_cpu(lp->rx_ring[entry].status) >> 8;
  6.1278 -
  6.1279 -	if (status != 0x03) {			/* There was an error. */
  6.1280 -	    /* 
  6.1281 -	     * There is a tricky error noted by John Murphy,
  6.1282 -	     * <murf@perftech.com> to Russ Nelson: Even with full-sized
  6.1283 -	     * buffers it's possible for a jabber packet to use two
  6.1284 -	     * buffers, with only the last correctly noting the error.
  6.1285 -	     */
  6.1286 -	    if (status & 0x01)	/* Only count a general error at the */
  6.1287 -		lp->stats.rx_errors++; /* end of a packet.*/
  6.1288 -	    if (status & 0x20) lp->stats.rx_frame_errors++;
  6.1289 -	    if (status & 0x10) lp->stats.rx_over_errors++;
  6.1290 -	    if (status & 0x08) lp->stats.rx_crc_errors++;
  6.1291 -	    if (status & 0x04) lp->stats.rx_fifo_errors++;
  6.1292 -	    lp->rx_ring[entry].status &= le16_to_cpu(0x03ff);
  6.1293 -	} else {
  6.1294 -	    /* Malloc up new buffer, compatible with net-2e. */
  6.1295 -	    short pkt_len = (le32_to_cpu(lp->rx_ring[entry].msg_length) & 0xfff)-4;
  6.1296 -	    struct sk_buff *skb;
  6.1297 -			
  6.1298 -	    if(pkt_len < 60) {
  6.1299 -		printk(KERN_ERR "%s: Runt packet!\n",dev->name);
  6.1300 -		lp->stats.rx_errors++;
  6.1301 -	    } else {
  6.1302 -		int rx_in_place = 0;
  6.1303 -
  6.1304 -		if (pkt_len > rx_copybreak) {
  6.1305 -		    struct sk_buff *newskb;
  6.1306 -				
  6.1307 -		    if ((newskb = dev_alloc_skb (PKT_BUF_SZ))) {
  6.1308 -			skb_reserve (newskb, 2);
  6.1309 -			skb = lp->rx_skbuff[entry];
  6.1310 -			skb_put (skb, pkt_len);
  6.1311 -			lp->rx_skbuff[entry] = newskb;
  6.1312 -			newskb->dev = dev;
  6.1313 -                        lp->rx_dma_addr[entry] = pci_map_single(lp->pci_dev, newskb->tail, newskb->len, PCI_DMA_FROMDEVICE);
  6.1314 -			lp->rx_ring[entry].base = le32_to_cpu(lp->rx_dma_addr[entry]);
  6.1315 -			rx_in_place = 1;
  6.1316 -		    } else
  6.1317 -			skb = NULL;
  6.1318 -		} else {
  6.1319 -		    skb = dev_alloc_skb(pkt_len+2);
  6.1320 -                }
  6.1321 -			    
  6.1322 -		if (skb == NULL) {
  6.1323 -                    int i;
  6.1324 -		    printk(KERN_ERR "%s: Memory squeeze, deferring packet.\n", dev->name);
  6.1325 -		    for (i = 0; i < RX_RING_SIZE; i++)
  6.1326 -			if ((short)le16_to_cpu(lp->rx_ring[(entry+i) & RX_RING_MOD_MASK].status) < 0)
  6.1327 -			    break;
  6.1328 -
  6.1329 -		    if (i > RX_RING_SIZE -2) {
  6.1330 -			lp->stats.rx_dropped++;
  6.1331 -			lp->rx_ring[entry].status |= le16_to_cpu(0x8000);
  6.1332 -			lp->cur_rx++;
  6.1333 -		    }
  6.1334 -		    break;
  6.1335 -		}
  6.1336 -		skb->dev = dev;
  6.1337 -		if (!rx_in_place) {
  6.1338 -		    skb_reserve(skb,2); /* 16 byte align */
  6.1339 -		    skb_put(skb,pkt_len);	/* Make room */
  6.1340 -		    eth_copy_and_sum(skb,
  6.1341 -				     (unsigned char *)(lp->rx_skbuff[entry]->tail),
  6.1342 -				     pkt_len,0);
  6.1343 -		}
  6.1344 -		lp->stats.rx_bytes += skb->len;
  6.1345 -		skb->protocol=eth_type_trans(skb,dev);
  6.1346 -		netif_rx(skb);
  6.1347 -		lp->stats.rx_packets++;
  6.1348 -	    }
  6.1349 -	}
  6.1350 -	/*
  6.1351 -	 * The docs say that the buffer length isn't touched, but Andrew Boyd
  6.1352 -	 * of QNX reports that some revs of the 79C965 clear it.
  6.1353 -	 */
  6.1354 -	lp->rx_ring[entry].buf_length = le16_to_cpu(-PKT_BUF_SZ);
  6.1355 -	lp->rx_ring[entry].status |= le16_to_cpu(0x8000);
  6.1356 -	entry = (++lp->cur_rx) & RX_RING_MOD_MASK;
  6.1357 -    }
  6.1358 -
  6.1359 -    return 0;
  6.1360 -}
  6.1361 -
  6.1362 -static int
  6.1363 -pcnet32_close(struct net_device *dev)
  6.1364 -{
  6.1365 -    unsigned long ioaddr = dev->base_addr;
  6.1366 -    struct pcnet32_private *lp = dev->priv;
  6.1367 -    int i;
  6.1368 -
  6.1369 -    netif_stop_queue(dev);
  6.1370 -
  6.1371 -    lp->stats.rx_missed_errors = lp->a.read_csr (ioaddr, 112);
  6.1372 -
  6.1373 -    if (pcnet32_debug > 1)
  6.1374 -	printk(KERN_DEBUG "%s: Shutting down ethercard, status was %2.2x.\n",
  6.1375 -	       dev->name, lp->a.read_csr (ioaddr, 0));
  6.1376 -
  6.1377 -    /* We stop the PCNET32 here -- it occasionally polls memory if we don't. */
  6.1378 -    lp->a.write_csr (ioaddr, 0, 0x0004);
  6.1379 -
  6.1380 -    /*
  6.1381 -     * Switch back to 16bit mode to avoid problems with dumb 
  6.1382 -     * DOS packet driver after a warm reboot
  6.1383 -     */
  6.1384 -    lp->a.write_bcr (ioaddr, 20, 4);
  6.1385 -
  6.1386 -    free_irq(dev->irq, dev);
  6.1387 -    
  6.1388 -    /* free all allocated skbuffs */
  6.1389 -    for (i = 0; i < RX_RING_SIZE; i++) {
  6.1390 -	lp->rx_ring[i].status = 0;			    
  6.1391 -	if (lp->rx_skbuff[i]) {
  6.1392 -            pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i], lp->rx_skbuff[i]->len, PCI_DMA_FROMDEVICE);
  6.1393 -	    dev_kfree_skb(lp->rx_skbuff[i]);
  6.1394 -        }
  6.1395 -	lp->rx_skbuff[i] = NULL;
  6.1396 -        lp->rx_dma_addr[i] = 0;
  6.1397 -    }
  6.1398 -    
  6.1399 -    for (i = 0; i < TX_RING_SIZE; i++) {
  6.1400 -	if (lp->tx_skbuff[i]) {
  6.1401 -            pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[i], lp->tx_skbuff[i]->len, PCI_DMA_TODEVICE);
  6.1402 -	    dev_kfree_skb(lp->tx_skbuff[i]);
  6.1403 -        }
  6.1404 -	lp->tx_skbuff[i] = NULL;
  6.1405 -        lp->tx_dma_addr[i] = 0;
  6.1406 -    }
  6.1407 -    
  6.1408 -    MOD_DEC_USE_COUNT;
  6.1409 -
  6.1410 -    return 0;
  6.1411 -}
  6.1412 -
  6.1413 -static struct net_device_stats *
  6.1414 -pcnet32_get_stats(struct net_device *dev)
  6.1415 -{
  6.1416 -    struct pcnet32_private *lp = dev->priv;
  6.1417 -    unsigned long ioaddr = dev->base_addr;
  6.1418 -    u16 saved_addr;
  6.1419 -    unsigned long flags;
  6.1420 -
  6.1421 -    spin_lock_irqsave(&lp->lock, flags);
  6.1422 -    saved_addr = lp->a.read_rap(ioaddr);
  6.1423 -    lp->stats.rx_missed_errors = lp->a.read_csr (ioaddr, 112);
  6.1424 -    lp->a.write_rap(ioaddr, saved_addr);
  6.1425 -    spin_unlock_irqrestore(&lp->lock, flags);
  6.1426 -
  6.1427 -    return &lp->stats;
  6.1428 -}
  6.1429 -
  6.1430 -/* taken from the sunlance driver, which it took from the depca driver */
  6.1431 -static void pcnet32_load_multicast (struct net_device *dev)
  6.1432 -{
  6.1433 -    struct pcnet32_private *lp = dev->priv;
  6.1434 -    volatile struct pcnet32_init_block *ib = &lp->init_block;
  6.1435 -    volatile u16 *mcast_table = (u16 *)&ib->filter;
  6.1436 -    struct dev_mc_list *dmi=dev->mc_list;
  6.1437 -    char *addrs;
  6.1438 -    int i, j, bit, byte;
  6.1439 -    u32 crc, poly = CRC_POLYNOMIAL_LE;
  6.1440 -	
  6.1441 -    /* set all multicast bits */
  6.1442 -    if (dev->flags & IFF_ALLMULTI){ 
  6.1443 -	ib->filter [0] = 0xffffffff;
  6.1444 -	ib->filter [1] = 0xffffffff;
  6.1445 -	return;
  6.1446 -    }
  6.1447 -    /* clear the multicast filter */
  6.1448 -    ib->filter [0] = 0;
  6.1449 -    ib->filter [1] = 0;
  6.1450 -
  6.1451 -    /* Add addresses */
  6.1452 -    for (i = 0; i < dev->mc_count; i++){
  6.1453 -	addrs = dmi->dmi_addr;
  6.1454 -	dmi   = dmi->next;
  6.1455 -	
  6.1456 -	/* multicast address? */
  6.1457 -	if (!(*addrs & 1))
  6.1458 -	    continue;
  6.1459 -	
  6.1460 -	crc = 0xffffffff;
  6.1461 -	for (byte = 0; byte < 6; byte++)
  6.1462 -	    for (bit = *addrs++, j = 0; j < 8; j++, bit >>= 1) {
  6.1463 -		int test;
  6.1464 -		
  6.1465 -		test = ((bit ^ crc) & 0x01);
  6.1466 -		crc >>= 1;
  6.1467 -		
  6.1468 -		if (test) {
  6.1469 -		    crc = crc ^ poly;
  6.1470 -		}
  6.1471 -	    }
  6.1472 -	
  6.1473 -	crc = crc >> 26;
  6.1474 -	mcast_table [crc >> 4] |= 1 << (crc & 0xf);
  6.1475 -    }
  6.1476 -    return;
  6.1477 -}
  6.1478 -
  6.1479 -
  6.1480 -/*
  6.1481 - * Set or clear the multicast filter for this adaptor.
  6.1482 - */
  6.1483 -static void pcnet32_set_multicast_list(struct net_device *dev)
  6.1484 -{
  6.1485 -    unsigned long ioaddr = dev->base_addr;
  6.1486 -    struct pcnet32_private *lp = dev->priv;	 
  6.1487 -
  6.1488 -    if (dev->flags&IFF_PROMISC) {
  6.1489 -	/* Log any net taps. */
  6.1490 -	printk(KERN_INFO "%s: Promiscuous mode enabled.\n", dev->name);
  6.1491 -	lp->init_block.mode = le16_to_cpu(0x8000 | (lp->options & PORT_PORTSEL) << 7);
  6.1492 -    } else {
  6.1493 -	lp->init_block.mode = le16_to_cpu((lp->options & PORT_PORTSEL) << 7);
  6.1494 -	pcnet32_load_multicast (dev);
  6.1495 -    }
  6.1496 -    
  6.1497 -    lp->a.write_csr (ioaddr, 0, 0x0004); /* Temporarily stop the lance. */
  6.1498 -
  6.1499 -    pcnet32_restart(dev, 0x0042); /*  Resume normal operation */
  6.1500 -}
  6.1501 -
  6.1502 -#ifdef HAVE_PRIVATE_IOCTL
  6.1503 -static int pcnet32_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  6.1504 -{
  6.1505 -    unsigned long ioaddr = dev->base_addr;
  6.1506 -    struct pcnet32_private *lp = dev->priv;	 
  6.1507 -    u16 *data = (u16 *)&rq->ifr_data;
  6.1508 -    int phyaddr = lp->a.read_bcr (ioaddr, 33);
  6.1509 -
  6.1510 -    if (lp->mii) {
  6.1511 -	switch(cmd) {
  6.1512 -	case SIOCDEVPRIVATE:		/* Get the address of the PHY in use. */
  6.1513 -	    data[0] = (phyaddr >> 5) & 0x1f;
  6.1514 -	    /* Fall Through */
  6.1515 -	case SIOCDEVPRIVATE+1:		/* Read the specified MII register. */
  6.1516 -	    lp->a.write_bcr (ioaddr, 33, ((data[0] & 0x1f) << 5) | (data[1] & 0x1f));
  6.1517 -	    data[3] = lp->a.read_bcr (ioaddr, 34);
  6.1518 -	    lp->a.write_bcr (ioaddr, 33, phyaddr);
  6.1519 -	    return 0;
  6.1520 -	case SIOCDEVPRIVATE+2:		/* Write the specified MII register */
  6.1521 -	    if (!capable(CAP_NET_ADMIN))
  6.1522 -		return -EPERM;
  6.1523 -	    lp->a.write_bcr (ioaddr, 33, ((data[0] & 0x1f) << 5) | (data[1] & 0x1f));
  6.1524 -	    lp->a.write_bcr (ioaddr, 34, data[2]);
  6.1525 -	    lp->a.write_bcr (ioaddr, 33, phyaddr);
  6.1526 -	    return 0;
  6.1527 -	default:
  6.1528 -	    return -EOPNOTSUPP;
  6.1529 -	}
  6.1530 -    }
  6.1531 -    return -EOPNOTSUPP;
  6.1532 -}
  6.1533 -#endif	/* HAVE_PRIVATE_IOCTL */
  6.1534 -					    
  6.1535 -static struct pci_driver pcnet32_driver = {
  6.1536 -    name:  "pcnet32",
  6.1537 -    probe: pcnet32_probe_pci,
  6.1538 -    remove: NULL,
  6.1539 -    id_table: pcnet32_pci_tbl,
  6.1540 -};
  6.1541 -
  6.1542 -MODULE_PARM(debug, "i");
  6.1543 -MODULE_PARM(max_interrupt_work, "i");
  6.1544 -MODULE_PARM(rx_copybreak, "i");
  6.1545 -MODULE_PARM(tx_start_pt, "i");
  6.1546 -MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i");
  6.1547 -MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
  6.1548 -MODULE_AUTHOR("Thomas Bogendoerfer");
  6.1549 -MODULE_DESCRIPTION("Driver for PCnet32 and PCnetPCI based ethercards");
  6.1550 -MODULE_LICENSE("GPL");
  6.1551 -
  6.1552 -/* An additional parameter that may be passed in... */
  6.1553 -static int debug = -1;
  6.1554 -static int tx_start_pt = -1;
  6.1555 -
  6.1556 -static int __init pcnet32_init_module(void)
  6.1557 -{
  6.1558 -    int cards_found = 0;
  6.1559 -    int err;
  6.1560 -
  6.1561 -    if (debug > 0)
  6.1562 -	pcnet32_debug = debug;
  6.1563 -    if ((tx_start_pt >= 0) && (tx_start_pt <= 3))
  6.1564 -	tx_start = tx_start_pt;
  6.1565 -    
  6.1566 -    pcnet32_dev = NULL;
  6.1567 -    /* find the PCI devices */
  6.1568 -#define USE_PCI_REGISTER_DRIVER
  6.1569 -#ifdef USE_PCI_REGISTER_DRIVER
  6.1570 -    if ((err = pci_module_init(&pcnet32_driver)) < 0 )
  6.1571 -       return err;
  6.1572 -#else
  6.1573 -    {
  6.1574 -        struct pci_device_id *devid = pcnet32_pci_tbl;
  6.1575 -        for (devid = pcnet32_pci_tbl; devid != NULL && devid->vendor != 0; devid++) {
  6.1576 -            struct pci_dev *pdev = pci_find_subsys(devid->vendor, devid->device, devid->subvendor, devid->subdevice, NULL);
  6.1577 -            if (pdev != NULL) {
  6.1578 -                if (pcnet32_probe_pci(pdev, devid) >= 0) {
  6.1579 -                    cards_found++;
  6.1580 -                }
  6.1581 -            }
  6.1582 -        }
  6.1583 -    }
  6.1584 -#endif
  6.1585 -    return 0;
  6.1586 -    /* find any remaining VLbus devices */
  6.1587 -    return pcnet32_probe_vlbus(cards_found);
  6.1588 -}
  6.1589 -
  6.1590 -static void __exit pcnet32_cleanup_module(void)
  6.1591 -{
  6.1592 -    struct net_device *next_dev;
  6.1593 -
  6.1594 -    /* No need to check MOD_IN_USE, as sys_delete_module() checks. */
  6.1595 -    while (pcnet32_dev) {
  6.1596 -        struct pcnet32_private *lp = pcnet32_dev->priv;
  6.1597 -	next_dev = lp->next;
  6.1598 -	unregister_netdev(pcnet32_dev);
  6.1599 -	release_region(pcnet32_dev->base_addr, PCNET32_TOTAL_SIZE);
  6.1600 -	if (lp->pci_dev != NULL)
  6.1601 -	    pci_unregister_driver(&pcnet32_driver);
  6.1602 -        pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
  6.1603 -	kfree(pcnet32_dev);
  6.1604 -	pcnet32_dev = next_dev;
  6.1605 -    }
  6.1606 -}
  6.1607 -
  6.1608 -module_init(pcnet32_init_module);
  6.1609 -module_exit(pcnet32_cleanup_module);
  6.1610 -
  6.1611 -/*
  6.1612 - * Local variables:
  6.1613 - *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c pcnet32.c"
  6.1614 - *  c-indent-level: 4
  6.1615 - *  tab-width: 8
  6.1616 - * End:
  6.1617 - */
     7.1 --- a/xen-2.4.16/drivers/net/tulip/.depend	Fri Feb 14 17:11:31 2003 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,58 +0,0 @@
     7.4 -21142.o: 21142.c \
     7.5 -   tulip.h \
     7.6 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/pci.h \
     7.7 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/delay.h
     7.8 -eeprom.o: eeprom.c \
     7.9 -   tulip.h \
    7.10 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/init.h \
    7.11 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/asm/unaligned.h
    7.12 -interrupt.o: interrupt.c \
    7.13 -   tulip.h \
    7.14 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/etherdevice.h \
    7.15 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/pci.h \
    7.16 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/net/hw/flowcontrol.h)
    7.17 -media.o: media.c \
    7.18 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/kernel.h \
    7.19 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/mii.h \
    7.20 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/init.h \
    7.21 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/delay.h \
    7.22 -   tulip.h
    7.23 -pnic2.o: pnic2.c \
    7.24 -   tulip.h \
    7.25 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/pci.h \
    7.26 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/delay.h
    7.27 -pnic.o: pnic.c \
    7.28 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/kernel.h \
    7.29 -   tulip.h
    7.30 -timer.o: timer.c \
    7.31 -   tulip.h
    7.32 -tulip_core.o: tulip_core.c \
    7.33 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/module.h \
    7.34 -   tulip.h \
    7.35 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/pci.h \
    7.36 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/init.h \
    7.37 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/etherdevice.h \
    7.38 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/delay.h \
    7.39 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/mii.h \
    7.40 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/ethtool.h \
    7.41 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/asm/unaligned.h \
    7.42 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/asm/uaccess.h \
    7.43 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/net/hw/flowcontrol.h) \
    7.44 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/tulip/mwi.h) \
    7.45 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/ddb5476.h) \
    7.46 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/ddb5477.h) \
    7.47 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/pm.h)
    7.48 -tulip.h: \
    7.49 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/kernel.h \
    7.50 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/types.h \
    7.51 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/spinlock.h \
    7.52 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/netdevice.h \
    7.53 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/timer.h \
    7.54 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/linux/delay.h \
    7.55 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/asm/io.h \
    7.56 -   /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/asm/irq.h \
    7.57 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/tulip/mmio.h) \
    7.58 -   $(wildcard /home/kaf24/xeno/build/linux-2.4.16-kdb-orig/include/config/net/hw/flowcontrol.h)
    7.59 -	@touch tulip.h
    7.60 -.PRECIOUS:	tulip.h \
    7.61 -
     8.1 --- a/xen-2.4.16/drivers/net/tulip/21142.c	Fri Feb 14 17:11:31 2003 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,239 +0,0 @@
     8.4 -/*
     8.5 -	drivers/net/tulip/21142.c
     8.6 -
     8.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
     8.8 -	Copyright 2000,2001  The Linux Kernel Team
     8.9 -	Written/copyright 1994-2001 by Donald Becker.
    8.10 -
    8.11 -	This software may be used and distributed according to the terms
    8.12 -	of the GNU General Public License, incorporated herein by reference.
    8.13 -
    8.14 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
    8.15 -	for more information on this driver, or visit the project
    8.16 -	Web page at http://sourceforge.net/projects/tulip/
    8.17 -
    8.18 -*/
    8.19 -
    8.20 -#include "tulip.h"
    8.21 -#include <linux/pci.h>
    8.22 -#include <linux/delay.h>
    8.23 -
    8.24 -
    8.25 -static u16 t21142_csr13[] = { 0x0001, 0x0009, 0x0009, 0x0000, 0x0001, };
    8.26 -u16 t21142_csr14[] =	    { 0xFFFF, 0x0705, 0x0705, 0x0000, 0x7F3D, };
    8.27 -static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
    8.28 -
    8.29 -
    8.30 -/* Handle the 21143 uniquely: do autoselect with NWay, not the EEPROM list
    8.31 -   of available transceivers.  */
    8.32 -void t21142_timer(unsigned long data)
    8.33 -{
    8.34 -	struct net_device *dev = (struct net_device *)data;
    8.35 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
    8.36 -	long ioaddr = dev->base_addr;
    8.37 -	int csr12 = inl(ioaddr + CSR12);
    8.38 -	int next_tick = 60*HZ;
    8.39 -	int new_csr6 = 0;
    8.40 -
    8.41 -	if (tulip_debug > 2)
    8.42 -		printk(KERN_INFO"%s: 21143 negotiation status %8.8x, %s.\n",
    8.43 -			   dev->name, csr12, medianame[dev->if_port]);
    8.44 -	if (tulip_media_cap[dev->if_port] & MediaIsMII) {
    8.45 -		tulip_check_duplex(dev);
    8.46 -		next_tick = 60*HZ;
    8.47 -	} else if (tp->nwayset) {
    8.48 -		/* Don't screw up a negotiated session! */
    8.49 -		if (tulip_debug > 1)
    8.50 -			printk(KERN_INFO"%s: Using NWay-set %s media, csr12 %8.8x.\n",
    8.51 -				   dev->name, medianame[dev->if_port], csr12);
    8.52 -	} else if (tp->medialock) {
    8.53 -			;
    8.54 -	} else if (dev->if_port == 3) {
    8.55 -		if (csr12 & 2) {	/* No 100mbps link beat, revert to 10mbps. */
    8.56 -			if (tulip_debug > 1)
    8.57 -				printk(KERN_INFO"%s: No 21143 100baseTx link beat, %8.8x, "
    8.58 -					   "trying NWay.\n", dev->name, csr12);
    8.59 -			t21142_start_nway(dev);
    8.60 -			next_tick = 3*HZ;
    8.61 -		}
    8.62 -	} else if ((csr12 & 0x7000) != 0x5000) {
    8.63 -		/* Negotiation failed.  Search media types. */
    8.64 -		if (tulip_debug > 1)
    8.65 -			printk(KERN_INFO"%s: 21143 negotiation failed, status %8.8x.\n",
    8.66 -				   dev->name, csr12);
    8.67 -		if (!(csr12 & 4)) {		/* 10mbps link beat good. */
    8.68 -			new_csr6 = 0x82420000;
    8.69 -			dev->if_port = 0;
    8.70 -			outl(0, ioaddr + CSR13);
    8.71 -			outl(0x0003FFFF, ioaddr + CSR14);
    8.72 -			outw(t21142_csr15[dev->if_port], ioaddr + CSR15);
    8.73 -			outl(t21142_csr13[dev->if_port], ioaddr + CSR13);
    8.74 -		} else {
    8.75 -			/* Select 100mbps port to check for link beat. */
    8.76 -			new_csr6 = 0x83860000;
    8.77 -			dev->if_port = 3;
    8.78 -			outl(0, ioaddr + CSR13);
    8.79 -			outl(0x0003FF7F, ioaddr + CSR14);
    8.80 -			outw(8, ioaddr + CSR15);
    8.81 -			outl(1, ioaddr + CSR13);
    8.82 -		}
    8.83 -		if (tulip_debug > 1)
    8.84 -			printk(KERN_INFO"%s: Testing new 21143 media %s.\n",
    8.85 -				   dev->name, medianame[dev->if_port]);
    8.86 -		if (new_csr6 != (tp->csr6 & ~0x00D5)) {
    8.87 -			tp->csr6 &= 0x00D5;
    8.88 -			tp->csr6 |= new_csr6;
    8.89 -			outl(0x0301, ioaddr + CSR12);
    8.90 -			tulip_restart_rxtx(tp);
    8.91 -		}
    8.92 -		next_tick = 3*HZ;
    8.93 -	}
    8.94 -
    8.95 -	/* mod_timer synchronizes us with potential add_timer calls
    8.96 -	 * from interrupts.
    8.97 -	 */
    8.98 -	mod_timer(&tp->timer, RUN_AT(next_tick));
    8.99 -}
   8.100 -
   8.101 -
   8.102 -void t21142_start_nway(struct net_device *dev)
   8.103 -{
   8.104 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   8.105 -	long ioaddr = dev->base_addr;
   8.106 -	int csr14 = ((tp->sym_advertise & 0x0780) << 9)  |
   8.107 -		((tp->sym_advertise & 0x0020) << 1) | 0xffbf;
   8.108 -
   8.109 -	dev->if_port = 0;
   8.110 -	tp->nway = tp->mediasense = 1;
   8.111 -	tp->nwayset = tp->lpar = 0;
   8.112 -	if (tulip_debug > 1)
   8.113 -		printk(KERN_DEBUG "%s: Restarting 21143 autonegotiation, csr14=%8.8x.\n",
   8.114 -			   dev->name, csr14);
   8.115 -	outl(0x0001, ioaddr + CSR13);
   8.116 -	udelay(100);
   8.117 -	outl(csr14, ioaddr + CSR14);
   8.118 -	tp->csr6 = 0x82420000 | (tp->sym_advertise & 0x0040 ? FullDuplex : 0);
   8.119 -	outl(tp->csr6, ioaddr + CSR6);
   8.120 -	if (tp->mtable  &&  tp->mtable->csr15dir) {
   8.121 -		outl(tp->mtable->csr15dir, ioaddr + CSR15);
   8.122 -		outl(tp->mtable->csr15val, ioaddr + CSR15);
   8.123 -	} else
   8.124 -		outw(0x0008, ioaddr + CSR15);
   8.125 -	outl(0x1301, ioaddr + CSR12); 		/* Trigger NWAY. */
   8.126 -}
   8.127 -
   8.128 -
   8.129 -
   8.130 -void t21142_lnk_change(struct net_device *dev, int csr5)
   8.131 -{
   8.132 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   8.133 -	long ioaddr = dev->base_addr;
   8.134 -	int csr12 = inl(ioaddr + CSR12);
   8.135 -
   8.136 -	if (tulip_debug > 1)
   8.137 -		printk(KERN_INFO"%s: 21143 link status interrupt %8.8x, CSR5 %x, "
   8.138 -			   "%8.8x.\n", dev->name, csr12, csr5, inl(ioaddr + CSR14));
   8.139 -
   8.140 -	/* If NWay finished and we have a negotiated partner capability. */
   8.141 -	if (tp->nway  &&  !tp->nwayset  &&  (csr12 & 0x7000) == 0x5000) {
   8.142 -		int setup_done = 0;
   8.143 -		int negotiated = tp->sym_advertise & (csr12 >> 16);
   8.144 -		tp->lpar = csr12 >> 16;
   8.145 -		tp->nwayset = 1;
   8.146 -		if (negotiated & 0x0100)		dev->if_port = 5;
   8.147 -		else if (negotiated & 0x0080)	dev->if_port = 3;
   8.148 -		else if (negotiated & 0x0040)	dev->if_port = 4;
   8.149 -		else if (negotiated & 0x0020)	dev->if_port = 0;
   8.150 -		else {
   8.151 -			tp->nwayset = 0;
   8.152 -			if ((csr12 & 2) == 0  &&  (tp->sym_advertise & 0x0180))
   8.153 -				dev->if_port = 3;
   8.154 -		}
   8.155 -		tp->full_duplex = (tulip_media_cap[dev->if_port] & MediaAlwaysFD) ? 1:0;
   8.156 -
   8.157 -		if (tulip_debug > 1) {
   8.158 -			if (tp->nwayset)
   8.159 -				printk(KERN_INFO "%s: Switching to %s based on link "
   8.160 -					   "negotiation %4.4x & %4.4x = %4.4x.\n",
   8.161 -					   dev->name, medianame[dev->if_port], tp->sym_advertise,
   8.162 -					   tp->lpar, negotiated);
   8.163 -			else
   8.164 -				printk(KERN_INFO "%s: Autonegotiation failed, using %s,"
   8.165 -					   " link beat status %4.4x.\n",
   8.166 -					   dev->name, medianame[dev->if_port], csr12);
   8.167 -		}
   8.168 -
   8.169 -		if (tp->mtable) {
   8.170 -			int i;
   8.171 -			for (i = 0; i < tp->mtable->leafcount; i++)
   8.172 -				if (tp->mtable->mleaf[i].media == dev->if_port) {
   8.173 -					tp->cur_index = i;
   8.174 -					tulip_select_media(dev, 1);
   8.175 -					setup_done = 1;
   8.176 -					break;
   8.177 -				}
   8.178 -		}
   8.179 -		if ( ! setup_done) {
   8.180 -			tp->csr6 = (dev->if_port & 1 ? 0x838E0000 : 0x82420000) | (tp->csr6 & 0x20ff);
   8.181 -			if (tp->full_duplex)
   8.182 -				tp->csr6 |= 0x0200;
   8.183 -			outl(1, ioaddr + CSR13);
   8.184 -		}
   8.185 -#if 0							/* Restart shouldn't be needed. */
   8.186 -		outl(tp->csr6 | RxOn, ioaddr + CSR6);
   8.187 -		if (tulip_debug > 2)
   8.188 -			printk(KERN_DEBUG "%s:  Restarting Tx and Rx, CSR5 is %8.8x.\n",
   8.189 -				   dev->name, inl(ioaddr + CSR5));
   8.190 -#endif
   8.191 -		tulip_start_rxtx(tp);
   8.192 -		if (tulip_debug > 2)
   8.193 -			printk(KERN_DEBUG "%s:  Setting CSR6 %8.8x/%x CSR12 %8.8x.\n",
   8.194 -				   dev->name, tp->csr6, inl(ioaddr + CSR6),
   8.195 -				   inl(ioaddr + CSR12));
   8.196 -	} else if ((tp->nwayset  &&  (csr5 & 0x08000000)
   8.197 -				&& (dev->if_port == 3  ||  dev->if_port == 5)
   8.198 -				&& (csr12 & 2) == 2) ||
   8.199 -			   (tp->nway && (csr5 & (TPLnkFail)))) {
   8.200 -		/* Link blew? Maybe restart NWay. */
   8.201 -		del_timer_sync(&tp->timer);
   8.202 -		t21142_start_nway(dev);
   8.203 -		tp->timer.expires = RUN_AT(3*HZ);
   8.204 -		add_timer(&tp->timer);
   8.205 -	} else if (dev->if_port == 3  ||  dev->if_port == 5) {
   8.206 -		if (tulip_debug > 1)
   8.207 -			printk(KERN_INFO"%s: 21143 %s link beat %s.\n",
   8.208 -				   dev->name, medianame[dev->if_port],
   8.209 -				   (csr12 & 2) ? "failed" : "good");
   8.210 -		if ((csr12 & 2)  &&  ! tp->medialock) {
   8.211 -			del_timer_sync(&tp->timer);
   8.212 -			t21142_start_nway(dev);
   8.213 -			tp->timer.expires = RUN_AT(3*HZ);
   8.214 -			add_timer(&tp->timer);
   8.215 -		} else if (dev->if_port == 5)
   8.216 -			outl(inl(ioaddr + CSR14) & ~0x080, ioaddr + CSR14);
   8.217 -	} else if (dev->if_port == 0  ||  dev->if_port == 4) {
   8.218 -		if ((csr12 & 4) == 0)
   8.219 -			printk(KERN_INFO"%s: 21143 10baseT link beat good.\n",
   8.220 -				   dev->name);
   8.221 -	} else if (!(csr12 & 4)) {		/* 10mbps link beat good. */
   8.222 -		if (tulip_debug)
   8.223 -			printk(KERN_INFO"%s: 21143 10mbps sensed media.\n",
   8.224 -				   dev->name);
   8.225 -		dev->if_port = 0;
   8.226 -	} else if (tp->nwayset) {
   8.227 -		if (tulip_debug)
   8.228 -			printk(KERN_INFO"%s: 21143 using NWay-set %s, csr6 %8.8x.\n",
   8.229 -				   dev->name, medianame[dev->if_port], tp->csr6);
   8.230 -	} else {		/* 100mbps link beat good. */
   8.231 -		if (tulip_debug)
   8.232 -			printk(KERN_INFO"%s: 21143 100baseTx sensed media.\n",
   8.233 -				   dev->name);
   8.234 -		dev->if_port = 3;
   8.235 -		tp->csr6 = 0x838E0000 | (tp->csr6 & 0x20ff);
   8.236 -		outl(0x0003FF7F, ioaddr + CSR14);
   8.237 -		outl(0x0301, ioaddr + CSR12);
   8.238 -		tulip_restart_rxtx(tp);
   8.239 -	}
   8.240 -}
   8.241 -
   8.242 -
     9.1 --- a/xen-2.4.16/drivers/net/tulip/ChangeLog	Fri Feb 14 17:11:31 2003 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,520 +0,0 @@
     9.4 -2001-11-13  David S. Miller  <davem@redhat.com>
     9.5 -
     9.6 -	* tulip_core.c (tulip_mwi_config): Kill unused label early_out.
     9.7 -
     9.8 -2001-11-06  Richard Mortimer  <richm@oldelvet.netscapeonline.co.uk>
     9.9 -
    9.10 -	* tulip_core.c:  Correct set of values to mask out of csr0,
    9.11 -	for DM9102A chips.  Limit burst/alignment of DM9102A chips
    9.12 -	on Sparcs.
    9.13 -
    9.14 -2001-11-06  Jun Sun  <jsun@mvista.com>
    9.15 -
    9.16 -	* tulip_core.c:  Support finding MAC address on
    9.17 -	two MIPS boards, DDB5476 and DDB5477.
    9.18 -
    9.19 -2001-11-06  Kevin B. Hendricks  <khendricks@ivey.uwo.ca>
    9.20 -
    9.21 -	* Makefile, tulip.h, tulip_core.c, pnic2.c, 21142.c:
    9.22 -	Fixes for PNIC II support.
    9.23 -
    9.24 -2001-11-06  David S. Miller  <davem@redhat.com>
    9.25 -
    9.26 -	* tulip_core.c: Support reading MAC address from
    9.27 -	Sparc OBP property local-mac-address.
    9.28 -
    9.29 -2001-07-17  Erik A. Hendriks  <hendriks@lanl.gov>
    9.30 -
    9.31 -	* 21142.c: Merge fix from tulip.c 0.92w which prevents the
    9.32 -	overwriting of csr6 bits we want to preserve.
    9.33 -
    9.34 -2001-07-10  Jeff Golds  <jgolds@resilience.com>
    9.35 -
    9.36 -	* tulip_core.c: Fix two comments
    9.37 -
    9.38 -2001-07-06  Stephen Degler  <sdegler@degler.net>
    9.39 -
    9.40 -	* media.c:
    9.41 -	The media selection process at the end of NWAY is busted
    9.42 -	because for the case of MII/SYM it needs to be:
    9.43 -
    9.44 -        csr13 <- 0
    9.45 -        csr14 <- 0
    9.46 -        csr6 <-  the value calculated is okay.
    9.47 -
    9.48 -	In the other media cases csr14 is computed by
    9.49 -	t21142_csr14val[dev->if_port], which seems ok.  The value of
    9.50 -	zero as opposed to 3FFFFF comes straight from appendix D of the
    9.51 -	21143 data book, and it makes logical sense because you're
    9.52 -	bypassing all the SIA interface when you usa MII or SYM (see
    9.53 -	figure 1-1 in the data book if your're visually oriented)
    9.54 -
    9.55 -2001-07-03  Jeff Golds  <jgolds@resilience.com>
    9.56 -
    9.57 -	* tulip_core.c (tulip_clean_tx_ring):
    9.58 -	Clear status for in-progress Tx's, and count
    9.59 -	Tx errors for all packets being released.
    9.60 -
    9.61 -2001-06-16  Jeff Garzik  <jgarzik@mandrakesoft.com>
    9.62 -
    9.63 -	* tulip.h, tulip_core.c:
    9.64 -	Integrate MMIO support from devel branch, but default
    9.65 -	it to off for stable kernel and driver series.
    9.66 -
    9.67 -2001-06-16  Jeff Garzik  <jgarzik@mandrakesoft.com>
    9.68 -
    9.69 -	* tulip_core.c (tulip_init_one):
    9.70 -	Free descriptor rings on error.
    9.71 -
    9.72 -2001-06-16  Jeff Garzik  <jgarzik@mandrakesoft.com>
    9.73 -
    9.74 -	* tulip_core.c (tulip_mwi_config, tulip_init_one):
    9.75 -	Large update to csr0 bus configuration code.  This is not stable
    9.76 -	yet, so it is only conditionally enabled, via CONFIG_TULIP_MWI.
    9.77 -
    9.78 -2001-06-16  Jeff Garzik  <jgarzik@mandrakesoft.com>
    9.79 -
    9.80 -	* tulip_core.c:
    9.81 -	Initialize timer in tulip_init_one and tulip_down,
    9.82 -	not in tulip_up.
    9.83 -
    9.84 -2001-06-14  Jeff Garzik  <jgarzik@mandrakesoft.com>
    9.85 -
    9.86 -	* tulip_core.c:
    9.87 -	- Update tulip_suspend, tulip_resume for new PCI PM API.
    9.88 -	- Surround suspend/resume code with CONFIG_PM.
    9.89 -
    9.90 -2001-06-12  Jeff Golds  <jgolds@resilience.com>
    9.91 -
    9.92 -	* tulip_core.c:
    9.93 -	- Reset sw ring ptrs in tulip_up.  Fixes PM resume case.
    9.94 -	- Clean rx and tx rings on device down.
    9.95 -
    9.96 -2001-06-05  David Miller  <davem@redhat.com>
    9.97 -
    9.98 -	* tulip_core (set_rx_mode):  Do not use set_bit
    9.99 -	on an integer variable.  Also fix endianness issue.
   9.100 -
   9.101 -2001-06-04  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.102 -
   9.103 -	* interrupt.c:
   9.104 -	Simplify rx processing when CONFIG_NET_HW_FLOWCONTROL is
   9.105 -	active, and in the process fix a bug where flow control
   9.106 -	and low load caused rx not to be acknowledged properly.
   9.107 -
   9.108 -2001-06-01  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.109 -
   9.110 -	* tulip.h:
   9.111 -	- Remove tulip_outl_csr helper, redundant.
   9.112 -	- Add tulip_start_rxtx inline helper.
   9.113 -	- tulip_stop_rxtx helper: Add synchronization. Always use current
   9.114 -	  csr6 value, instead of tp->csr6 value or value passed as arg.
   9.115 -	- tulip_restart_rxtx helper: Add synchronization. Always
   9.116 -	  use tp->csr6 for desired mode, not value passed as arg.
   9.117 -	- New RxOn, TxOn, RxTx constants for csr6 modes.
   9.118 -	- Remove now-redundant constants csr6_st, csr6_sr.
   9.119 -
   9.120 -	* 21142.c, interrupt.c, media.c, pnic.c, tulip_core.c:
   9.121 -	Update for above rxtx helper changes.
   9.122 -
   9.123 -	* interrupt.c:
   9.124 -	- whitespace cleanup around #ifdef CONFIG_NET_HW_FLOWCONTROL,
   9.125 -	  convert tabs to spaces.
   9.126 -	- Move tp->stats.rx_missed_errors update outside the ifdef.
   9.127 -
   9.128 -2001-05-18  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.129 -
   9.130 -	* tulip_core.c: Added ethtool support.
   9.131 -	  ETHTOOL_GDRVINFO ioctl only, for now.
   9.132 -
   9.133 -2001-05-14  Robert Olsson <Robert.Olsson@data.slu.se>
   9.134 -
   9.135 -	* Restored HW_FLOWCONTROL from Linux 2.1 series tulip (ANK)
   9.136 -	  plus Jamal's NETIF_RX_* feedback control.
   9.137 -
   9.138 -2001-05-14  Robert Olsson <Robert.Olsson@data.slu.se>
   9.139 -
   9.140 -	* Added support for 21143's Interrupt Mitigation.
   9.141 -	  Jamal original instigator.
   9.142 -
   9.143 -2001-05-14  Robert Olsson <Robert.Olsson@data.slu.se>
   9.144 -
   9.145 -	* tulip_refill_rx prototype added to tulip.h
   9.146 -
   9.147 -2001-05-13  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.148 -
   9.149 -	* tulip_core.c: Remove HAS_PCI_MWI flag from Comet, untested.
   9.150 -
   9.151 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.152 -
   9.153 -	* tulip_core.c, tulip.h: Remove Conexant PCI id, no chip
   9.154 -	docs are available to fix problems with support.
   9.155 -
   9.156 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.157 -
   9.158 -	* tulip_core.c (tulip_init_one): Do not call
   9.159 -	unregister_netdev in error cleanup.  Remnant of old
   9.160 -	usage of init_etherdev.
   9.161 -
   9.162 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.163 -
   9.164 -	* media.c (tulip_find_mii): Simple write the updated BMCR
   9.165 -	twice, as it seems the best thing to do for both broken and
   9.166 -	sane chips.
   9.167 -	If the mii_advert value, as read from MII_ADVERTISE, is zero,
   9.168 -	then generate a value we should advertise from the capability
   9.169 -	bits in BMSR.
   9.170 -	Fill in tp->advertising for all cases.
   9.171 -	Just to be safe, clear all unwanted bits.
   9.172 -
   9.173 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.174 -
   9.175 -	* tulip_core.c (private_ioctl):  Fill in tp->advertising
   9.176 -	when advertising value is changed by the user.
   9.177 -
   9.178 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.179 -
   9.180 -	* tulip_core.c: Mark Comet chips as needed the updated MWI
   9.181 -	csr0 configuration.
   9.182 -
   9.183 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.184 -
   9.185 -	* media.c, tulip_core.c:  Move MII scan into
   9.186 -	from inlined inside tulip_init_one to new function
   9.187 -	tulip_find_mii in media.c.
   9.188 -
   9.189 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.190 -
   9.191 -	* media.c (tulip_check_duplex):
   9.192 -	Only restart Rx/Tx engines if they are active
   9.193 -	(and csr6 changes)
   9.194 -
   9.195 -2001-05-12  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.196 -
   9.197 -	* tulip_core.c (tulip_mwi_config):
   9.198 -	Clamp values read from PCI cache line size register to
   9.199 -	values acceptable to tulip chip.  Done for safety and
   9.200 -	-almost- certainly unneeded.
   9.201 -
   9.202 -2001-05-11  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.203 -
   9.204 -	* tulip_core.c (tulip_init_one):
   9.205 -	Instead of unconditionally enabling autonegotiation, disable
   9.206 -	autonegotiation if not using the default port.  Further,
   9.207 -	flip the nway bit immediately, and then update the
   9.208 -	speed/duplex in a separate MII transaction.  We do this
   9.209 -	because some boards require that nway be disabled separately,
   9.210 -	before media selection is forced.
   9.211 -
   9.212 -	TODO: Investigate if we can simply write the same value
   9.213 -	to BMCR twice, to avoid setting unnecessarily changing
   9.214 -	phy settings.
   9.215 -
   9.216 -2001-05-11  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.217 -
   9.218 -	* tulip.h, tulip_core.c:  If HAS_PCI_MWI is set for a
   9.219 -	given chip, adjust the csr0 values not according to
   9.220 -	provided values but according to system cache line size.
   9.221 -	Currently cache alignment is matched as closely to cache
   9.222 -	line size as possible.  Currently programmable burst limit
   9.223 -	is set (ie. never unlimited), and always equal to cache
   9.224 -	alignment and system cache size.  Currently MWI bit is set
   9.225 -	only if the MWI bit is present in the PCI command register.
   9.226 -
   9.227 -2001-05-11  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.228 -
   9.229 -	* media.c (tulip_select_media):
   9.230 -	For media types 1 and 3, only use the provided eeprom
   9.231 -	advertising value if it is non-zero.
   9.232 -	(tulip_check_duplex):
   9.233 -	Do not exit ASAP if full_duplex_lock is set.  This
   9.234 -	ensures that the csr6 value is written if an update
   9.235 -	is needed.
   9.236 -
   9.237 -2001-05-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.238 -
   9.239 -	Merge PNIC-II-specific stuff from Becker's tulip.c:
   9.240 -
   9.241 -	* tulip.h, 21142.c (pnic2_lnk_change): new function
   9.242 -	* tulip_core.c (tulip_init_one): use it
   9.243 -
   9.244 -	* tulip_core.c (tulip_tx_timeout): Add specific
   9.245 -	debugging for PNIC2.
   9.246 -
   9.247 -2001-05-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.248 -
   9.249 -	* tulip_core.c (tulip_init_one): Print out
   9.250 -	tulip%d instead of PCI device number, for
   9.251 -	consistency.
   9.252 -
   9.253 -2001-05-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.254 -
   9.255 -	* Merge changes from Becker's tulip.c:
   9.256 -	Fix bugs in ioctl.
   9.257 -	Fix several bugs by distinguishing between MII
   9.258 -	and SYM advertising values.
   9.259 -	Set CSR14 autonegotiation bit for media types 2 and 4,
   9.260 -	where the SIA CSR setup values are not provided.
   9.261 -
   9.262 -2001-05-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.263 -
   9.264 -	* media.c (tulip_select_media): Only update MII
   9.265 -	advertising value if startup arg < 2.
   9.266 -
   9.267 -	* tulip.h: Do not enable CSR13/14/15 autoconfiguration
   9.268 -	for 21041.
   9.269 -
   9.270 -	* tulip_core.c:
   9.271 -	21041: add specific code for reset, and do not set CAC bit
   9.272 -	When resetting media, for media table type 11 media, pass
   9.273 -	value 2 as 'startup' arg to select_media, to avoid updating
   9.274 -	MII advertising value.
   9.275 -
   9.276 -2001-05-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.277 -
   9.278 -	* pnic.c (pnic_check_duplex): remove
   9.279 -	pnic.c (pnic_lnk_change, pnic_timer): use
   9.280 -	tulip_check_duplex not pnic_check_duplex.
   9.281 -
   9.282 -	* media.c (tulip_check_duplex):
   9.283 -	Clean up to use symbolic names instead of numeric constants.
   9.284 -	Set TxThreshold mode as necessary as well as clearing it.
   9.285 -	Update csr6 if csr6 changes, not simply if duplex changes.
   9.286 -
   9.287 -	(found by Manfred Spraul)
   9.288 -
   9.289 -2001-05-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.290 -
   9.291 -	* 21142.c, eeprom.c, tulip.h, tulip_core.c:
   9.292 -	Remove DPRINTK as another, better method of
   9.293 -	debug message printing is available.
   9.294 -
   9.295 -2001-05-09  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.296 -
   9.297 -	* 21142.c (t21142_lnk_change): Pass arg startup==1
   9.298 -	to tulip_select_media, in order to force csr13 to be
   9.299 -	zeroed out prior to going to full duplex mode.  Fixes
   9.300 -	autonegotiation on a quad-port Znyx card.
   9.301 -	(from Stephen Dengler)
   9.302 -
   9.303 -2001-05-09  Russell King  <rmk@arm.linux.org.uk>
   9.304 -
   9.305 -	* interrupt.c: Better PCI bus error reporting.
   9.306 -
   9.307 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.308 -
   9.309 -	* tulip_core.c: Now that dev->name is only available late
   9.310 -	  in the probe, insert a hack to replace a not-evaluated
   9.311 -	  "eth%d" string with an evaluated "tulip%d" string.
   9.312 -	  Also, remove obvious comment and an indentation cleanup.
   9.313 -
   9.314 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.315 -
   9.316 -	* tulip_core.c: If we are a module, always print out the
   9.317 -	  version string.  If we are built into the kernel, only print
   9.318 -	  the version string if at least one tulip is detected.
   9.319 -
   9.320 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.321 -
   9.322 -	Merged from Becker's tulip.c 0.92t:
   9.323 -
   9.324 -	* tulip_core.c: Add support for Conexant LANfinity.
   9.325 -
   9.326 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.327 -
   9.328 -	* tulip_core.c: Only suspend/resume if the interface
   9.329 -	  is up and running.  Use alloc_etherdev and pci_request_regions.
   9.330 -	  Spelling fix.
   9.331 -
   9.332 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.333 -
   9.334 -	* tulip_core.c: Remove code that existed when one or more of
   9.335 -	  the following defines existed.  These defines were never used
   9.336 -	  by normal users in practice: TULIP_FULL_DUPLEX,
   9.337 -	  TULIP_DEFAULT_MEDIA, and TULIP_NO_MEDIA_SWITCH.
   9.338 -
   9.339 -	* tulip.h, eeprom.c: Move EE_* constants from tulip.h to eeprom.c.
   9.340 -	* tulip.h, media.c: Move MDIO_* constants from tulip.h to media.c.
   9.341 -
   9.342 -	* media.c: Add barrier() to mdio_read/write's PNIC status check
   9.343 -	  loops.
   9.344 -
   9.345 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.346 -
   9.347 -	Merged from Becker's tulip.c 0.92t:
   9.348 -
   9.349 -	* tulip.h: Add MEDIA_MASK constant for bounding medianame[]
   9.350 -	  array lookups.
   9.351 -	* eeprom.c, media.c, timer.c, tulip_core.c: Use it.
   9.352 -
   9.353 -	* media.c, tulip_core.c: mdio_{read,write} cleanup.  Since this
   9.354 -	  is called [pretty much] directly from ioctl, we mask
   9.355 -	  read/write arguments to limit the values passed.
   9.356 -	  Added mii_lock.  Added comet_miireg2offset and better
   9.357 -	  Comet-specific mdio_read/write code.	Pay closer attention
   9.358 -	  to the bits we set in ioctl.	Remove spinlocks from ioctl,
   9.359 -	  they are in mdio_read/write now.  Use mask to limit
   9.360 -	  phy number in tulip_init_one's MII scan.
   9.361 -
   9.362 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.363 -
   9.364 -	Merged from Becker's tulip.c 0.92t:
   9.365 -
   9.366 -	* 21142.c, tulip_core.c: PNIC2 MAC address and NWay fixes.
   9.367 -	* tulip.h: Add FullDuplex constant, used in above change.
   9.368 -
   9.369 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.370 -
   9.371 -	* timer.c: Do not call netif_carrier_{on,off}, it is not used in
   9.372 -	  the main tree.  Leave code in, disabled, as markers for future
   9.373 -	  carrier notification.
   9.374 -
   9.375 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.376 -
   9.377 -	Merged from Becker's tulip.c 0.92t, except for the tulip.h
   9.378 -	whitespace cleanup:
   9.379 -
   9.380 -	* interrupt.c: If Rx stops, make sure to update the
   9.381 -	  multicast filter before restarting.
   9.382 -	* tulip.h: Add COMET_MAC_ADDR feature flag, clean up flags.
   9.383 -	  Add Accept* Rx mode bit constants.
   9.384 -	  Add mc_filter[] to driver private struct.
   9.385 -	* tulip_core.c: Add new Comet PCI id 0x1113:0x9511.
   9.386 -	  Add COMET_MAC_ADDR feature flag to comet entry in board info array.
   9.387 -	  Prefer to test COMET_MAC_ADDR flag to testing chip_id for COMET,
   9.388 -	  when dealing with the Comet's MAC address.
   9.389 -	  Enable Tx underrun recovery for Comet chips.
   9.390 -	  Use new Accept* constants in set_rx_mode.
   9.391 -	  Prefer COMET_MAC_ADDR flag test to chip_id test in set_rx_mode.
   9.392 -	  Store built mc_filter for later use in intr handler by Comets.
   9.393 -
   9.394 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.395 -
   9.396 -	* tulip_core.c: Use tp->cur_tx when building the
   9.397 -	  setup frame, instead of assuming that the setup
   9.398 -	  frame is always built in slot zero.  This case is
   9.399 -	  hit during PM resume.
   9.400 -
   9.401 -2001-04-03  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.402 -
   9.403 -	* *.c: Update file headers (copyright, urls, etc.)
   9.404 -	* Makefile: re-order to that chip-specific modules on own line
   9.405 -	* eeprom.c: BSS/zero-init cleanup (Andrey Panin)
   9.406 -	* tulip_core.c: merge medianame[] update from tulip.c.
   9.407 -	  Additional arch-specific rx_copybreak, csr0 values. (various)
   9.408 -
   9.409 -2001-02-20  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.410 -
   9.411 -	* media.c (tulip_select_media): No need to initialize
   9.412 -	new_csr6, all cases initialize it properly.
   9.413 -
   9.414 -2001-02-18  Manfred Spraul  <manfred@colorfullife.com>
   9.415 -
   9.416 -	* interrupt.c (tulip_refill_rx): Make public.
   9.417 -	If PNIC chip stops due to lack of Rx buffers, restart it.
   9.418 -	(tulip_interrupt): PNIC doesn't have a h/w timer, emulate
   9.419 -	with software timers.
   9.420 -	* pnic.c (pnic_check_duplex): New function, PNIC-specific
   9.421 -	version of tulip_check_duplex.
   9.422 -	(pnic_lnk_change): Call pnic_check_duplex.  If we use an
   9.423 -	external MII, then we mustn't use the internal negotiation.
   9.424 -	(pnic_timer): Support Rx refilling on work overflow in
   9.425 -	interrupt handler, as PNIC doesn't support a h/w timer.
   9.426 -	* tulip_core.c (tulip_tbl[]): Modify default csr6
   9.427 -
   9.428 -2001-02-11  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.429 -
   9.430 -	* tulip_core.c (tulip_init_one): Call pci_enable_device
   9.431 -	to ensure wakeup/resource assignment before checking those
   9.432 -	values.
   9.433 -	(tulip_init_one): Replace PCI ids with constants from pci_id.h.
   9.434 -	(tulip_suspend, tulip_resume, tulip_remove_one): Call
   9.435 -	pci_power_on/off (commented out for now).
   9.436 -
   9.437 -2001-02-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.438 -
   9.439 -	* tulip.h: Add CFDD_xxx bits for Tulip power management
   9.440 -	* tulip_core.c (tulip_set_power_state): New function,
   9.441 -	manipulating Tulip chip power state where supported.
   9.442 -	(tulip_up, tulip_down, tulip_init_one): Use it.
   9.443 -
   9.444 -2001-02-10  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.445 -
   9.446 -	* tulip_core.c (tulip_tx_timeout): Call netif_wake_queue
   9.447 -	to ensure the next Tx is always sent to us.
   9.448 -
   9.449 -2001-01-27  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.450 -
   9.451 -	* tulip_core.c (tulip_remove_one): Fix mem leak by freeing
   9.452 -	tp->media_tbl.  Add check for !dev, reformat code appropriately.
   9.453 -
   9.454 -2001-01-27  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.455 -
   9.456 -	* tulip_tbl[]: Comment all entries to make order and chip_id
   9.457 -	relationship more clear.
   9.458 -	* tulip_pci_tbl[]: Add new Accton PCI id (COMET chipset).
   9.459 -
   9.460 -2001-01-16  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.461 -
   9.462 -	* tulip_core.c: static vars no longer explicitly
   9.463 -	initialized to zero.
   9.464 -	* eeprom.c (tulip_read_eeprom): Make sure to delay between
   9.465 -	EE_ENB and EE_ENB|EE_SHIFT_CLK.  Merged from becker tulip.c.
   9.466 -
   9.467 -2001-01-05  Peter De Schrijver  <p2@mind.be>
   9.468 -
   9.469 -	* eeprom.c (tulip_parse_eeprom): Interpret a bit more of 21142
   9.470 -	extended format type 3 info blocks in a tulip SROM.
   9.471 -
   9.472 -2001-01-03  Matti Aarnio  <matti.aarnio@zmailer.org>
   9.473 -
   9.474 -	* media.c (tulip_select_media): Support media types 5 and 6
   9.475 -
   9.476 -2001-??-??  ??
   9.477 -
   9.478 -	* tulip_core.c: Add comment about LanMedia needing
   9.479 -	a different driver.
   9.480 -	Enable workarounds for early PCI chipsets.
   9.481 -	Add IA64 csr0 support, update HPPA csr0 support.
   9.482 -
   9.483 -2000-12-17  Alan Cox  <alan@redhat.com>
   9.484 -
   9.485 -        * eeprom.c, timer.c, tulip.h, tulip_core.c: Merge support
   9.486 -	for the Davicom's quirks into the main tulip.
   9.487 -	Patch by Tobias Ringstrom
   9.488 -
   9.489 -2000-11-08  Jim Studt  <jim@federated.com>
   9.490 -
   9.491 -	* eeprom.c (tulip_parse_eeprom):  Check array bounds for
   9.492 -	medianame[] and block_name[] arrays to avoid oops due
   9.493 -	to bad values returned from hardware.
   9.494 -
   9.495 -2000-11-02  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.496 -
   9.497 -	* tulip_core.c (set_rx_mode): This is synchronized via
   9.498 -	dev->xmit_lock, so only the queueing of the setup frame needs to
   9.499 -	be locked, against tulip_interrupt.
   9.500 -
   9.501 -2000-11-02  Alexey Kuznetov  <kuznet@ms2.inr.ac.ru>
   9.502 -
   9.503 -	* timer.c (tulip_timer): Call netif_carrier_{on,off} to report
   9.504 -	link state to the rest of the kernel, and userspace.
   9.505 -	* interrupt.c (tulip_interrupt): Remove tx_full.
   9.506 -	* tulip.h: Likewise.
   9.507 -	* tulip_core.c (tulip_init_ring, tulip_start_xmit, set_rx_mode):
   9.508 -	Likewise.
   9.509 -
   9.510 -2000-10-18  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.511 -
   9.512 -	* tulip_core.c: (tulip_init_one) Print out ethernet interface
   9.513 -	on error.  Print out a message when pci_enable_device fails.
   9.514 -	Handle DMA alloc failure.
   9.515 -
   9.516 -2000-10-18  Jeff Garzik  <jgarzik@mandrakesoft.com>
   9.517 -
   9.518 -	* Makefile: New file.
   9.519 -	* tulip_core.c (tulip_init_one): Correct error messages
   9.520 -	on PIO/MMIO region reserve failure.
   9.521 -	(tulip_init_one) Add new check to ensure that PIO region is
   9.522 -	sufficient for our needs.
   9.523 -
    10.1 --- a/xen-2.4.16/drivers/net/tulip/Makefile	Fri Feb 14 17:11:31 2003 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,8 +0,0 @@
    10.4 -
    10.5 -include $(BASEDIR)/Rules.mk
    10.6 -
    10.7 -default: $(OBJS)
    10.8 -	$(LD) -r -o tulip.o $(OBJS)
    10.9 -
   10.10 -clean:
   10.11 -	rm -f *.o *~ core
    11.1 --- a/xen-2.4.16/drivers/net/tulip/eeprom.c	Fri Feb 14 17:11:31 2003 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,320 +0,0 @@
    11.4 -/*
    11.5 -	drivers/net/tulip/eeprom.c
    11.6 -
    11.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
    11.8 -	Copyright 2000,2001  The Linux Kernel Team
    11.9 -	Written/copyright 1994-2001 by Donald Becker.
   11.10 -
   11.11 -	This software may be used and distributed according to the terms
   11.12 -	of the GNU General Public License, incorporated herein by reference.
   11.13 -
   11.14 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   11.15 -	for more information on this driver, or visit the project
   11.16 -	Web page at http://sourceforge.net/projects/tulip/
   11.17 -
   11.18 -*/
   11.19 -
   11.20 -#include "tulip.h"
   11.21 -#include <linux/init.h>
   11.22 -#include <asm/unaligned.h>
   11.23 -
   11.24 -
   11.25 -
   11.26 -/* Serial EEPROM section. */
   11.27 -/* The main routine to parse the very complicated SROM structure.
   11.28 -   Search www.digital.com for "21X4 SROM" to get details.
   11.29 -   This code is very complex, and will require changes to support
   11.30 -   additional cards, so I'll be verbose about what is going on.
   11.31 -   */
   11.32 -
   11.33 -/* Known cards that have old-style EEPROMs. */
   11.34 -static struct eeprom_fixup eeprom_fixups[] __devinitdata = {
   11.35 -  {"Asante", 0, 0, 0x94, {0x1e00, 0x0000, 0x0800, 0x0100, 0x018c,
   11.36 -			  0x0000, 0x0000, 0xe078, 0x0001, 0x0050, 0x0018 }},
   11.37 -  {"SMC9332DST", 0, 0, 0xC0, { 0x1e00, 0x0000, 0x0800, 0x041f,
   11.38 -			   0x0000, 0x009E, /* 10baseT */
   11.39 -			   0x0004, 0x009E, /* 10baseT-FD */
   11.40 -			   0x0903, 0x006D, /* 100baseTx */
   11.41 -			   0x0905, 0x006D, /* 100baseTx-FD */ }},
   11.42 -  {"Cogent EM100", 0, 0, 0x92, { 0x1e00, 0x0000, 0x0800, 0x063f,
   11.43 -				 0x0107, 0x8021, /* 100baseFx */
   11.44 -				 0x0108, 0x8021, /* 100baseFx-FD */
   11.45 -				 0x0100, 0x009E, /* 10baseT */
   11.46 -				 0x0104, 0x009E, /* 10baseT-FD */
   11.47 -				 0x0103, 0x006D, /* 100baseTx */
   11.48 -				 0x0105, 0x006D, /* 100baseTx-FD */ }},
   11.49 -  {"Maxtech NX-110", 0, 0, 0xE8, { 0x1e00, 0x0000, 0x0800, 0x0513,
   11.50 -				   0x1001, 0x009E, /* 10base2, CSR12 0x10*/
   11.51 -				   0x0000, 0x009E, /* 10baseT */
   11.52 -				   0x0004, 0x009E, /* 10baseT-FD */
   11.53 -				   0x0303, 0x006D, /* 100baseTx, CSR12 0x03 */
   11.54 -				   0x0305, 0x006D, /* 100baseTx-FD CSR12 0x03 */}},
   11.55 -  {"Accton EN1207", 0, 0, 0xE8, { 0x1e00, 0x0000, 0x0800, 0x051F,
   11.56 -				  0x1B01, 0x0000, /* 10base2,   CSR12 0x1B */
   11.57 -				  0x0B00, 0x009E, /* 10baseT,   CSR12 0x0B */
   11.58 -				  0x0B04, 0x009E, /* 10baseT-FD,CSR12 0x0B */
   11.59 -				  0x1B03, 0x006D, /* 100baseTx, CSR12 0x1B */
   11.60 -				  0x1B05, 0x006D, /* 100baseTx-FD CSR12 0x1B */
   11.61 -   }},
   11.62 -  {"NetWinder", 0x00, 0x10, 0x57,
   11.63 -	/* Default media = MII
   11.64 -	 * MII block, reset sequence (3) = 0x0821 0x0000 0x0001, capabilities 0x01e1
   11.65 -	 */
   11.66 -	{ 0x1e00, 0x0000, 0x000b, 0x8f01, 0x0103, 0x0300, 0x0821, 0x000, 0x0001, 0x0000, 0x01e1 }
   11.67 -  },
   11.68 -  {0, 0, 0, 0, {}}};
   11.69 -
   11.70 -
   11.71 -static const char *block_name[] __devinitdata = {
   11.72 -	"21140 non-MII",
   11.73 -	"21140 MII PHY",
   11.74 -	"21142 Serial PHY",
   11.75 -	"21142 MII PHY",
   11.76 -	"21143 SYM PHY",
   11.77 -	"21143 reset method"
   11.78 -};
   11.79 -
   11.80 -
   11.81 -void __devinit tulip_parse_eeprom(struct net_device *dev)
   11.82 -{
   11.83 -	/* The last media info list parsed, for multiport boards.  */
   11.84 -	static struct mediatable *last_mediatable;
   11.85 -	static unsigned char *last_ee_data;
   11.86 -	static int controller_index;
   11.87 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   11.88 -	unsigned char *ee_data = tp->eeprom;
   11.89 -	int i;
   11.90 -
   11.91 -	tp->mtable = 0;
   11.92 -	/* Detect an old-style (SA only) EEPROM layout:
   11.93 -	   memcmp(eedata, eedata+16, 8). */
   11.94 -	for (i = 0; i < 8; i ++)
   11.95 -		if (ee_data[i] != ee_data[16+i])
   11.96 -			break;
   11.97 -	if (i >= 8) {
   11.98 -		if (ee_data[0] == 0xff) {
   11.99 -			if (last_mediatable) {
  11.100 -				controller_index++;
  11.101 -				printk(KERN_INFO "%s:  Controller %d of multiport board.\n",
  11.102 -					   dev->name, controller_index);
  11.103 -				tp->mtable = last_mediatable;
  11.104 -				ee_data = last_ee_data;
  11.105 -				goto subsequent_board;
  11.106 -			} else
  11.107 -				printk(KERN_INFO "%s:  Missing EEPROM, this interface may "
  11.108 -					   "not work correctly!\n",
  11.109 -			   dev->name);
  11.110 -			return;
  11.111 -		}
  11.112 -	  /* Do a fix-up based on the vendor half of the station address prefix. */
  11.113 -	  for (i = 0; eeprom_fixups[i].name; i++) {
  11.114 -		if (dev->dev_addr[0] == eeprom_fixups[i].addr0
  11.115 -			&&  dev->dev_addr[1] == eeprom_fixups[i].addr1
  11.116 -			&&  dev->dev_addr[2] == eeprom_fixups[i].addr2) {
  11.117 -		  if (dev->dev_addr[2] == 0xE8  &&  ee_data[0x1a] == 0x55)
  11.118 -			  i++;			/* An Accton EN1207, not an outlaw Maxtech. */
  11.119 -		  memcpy(ee_data + 26, eeprom_fixups[i].newtable,
  11.120 -				 sizeof(eeprom_fixups[i].newtable));
  11.121 -		  printk(KERN_INFO "%s: Old format EEPROM on '%s' board.  Using"
  11.122 -				 " substitute media control info.\n",
  11.123 -				 dev->name, eeprom_fixups[i].name);
  11.124 -		  break;
  11.125 -		}
  11.126 -	  }
  11.127 -	  if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
  11.128 -		  printk(KERN_INFO "%s: Old style EEPROM with no media selection "
  11.129 -				 "information.\n",
  11.130 -			   dev->name);
  11.131 -		return;
  11.132 -	  }
  11.133 -	}
  11.134 -
  11.135 -	controller_index = 0;
  11.136 -	if (ee_data[19] > 1) {		/* Multiport board. */
  11.137 -		last_ee_data = ee_data;
  11.138 -	}
  11.139 -subsequent_board:
  11.140 -
  11.141 -	if (ee_data[27] == 0) {		/* No valid media table. */
  11.142 -	} else if (tp->chip_id == DC21041) {
  11.143 -		unsigned char *p = (void *)ee_data + ee_data[27 + controller_index*3];
  11.144 -		int media = get_u16(p);
  11.145 -		int count = p[2];
  11.146 -		p += 3;
  11.147 -
  11.148 -		printk(KERN_INFO "%s: 21041 Media table, default media %4.4x (%s).\n",
  11.149 -			   dev->name, media,
  11.150 -			   media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]);
  11.151 -		for (i = 0; i < count; i++) {
  11.152 -			unsigned char media_block = *p++;
  11.153 -			int media_code = media_block & MEDIA_MASK;
  11.154 -			if (media_block & 0x40)
  11.155 -				p += 6;
  11.156 -			printk(KERN_INFO "%s:  21041 media #%d, %s.\n",
  11.157 -				   dev->name, media_code, medianame[media_code]);
  11.158 -		}
  11.159 -	} else {
  11.160 -		unsigned char *p = (void *)ee_data + ee_data[27];
  11.161 -		unsigned char csr12dir = 0;
  11.162 -		int count, new_advertise = 0;
  11.163 -		struct mediatable *mtable;
  11.164 -		u16 media = get_u16(p);
  11.165 -
  11.166 -		p += 2;
  11.167 -		if (tp->flags & CSR12_IN_SROM)
  11.168 -			csr12dir = *p++;
  11.169 -		count = *p++;
  11.170 -
  11.171 -	        /* there is no phy information, don't even try to build mtable */
  11.172 -	        if (count == 0) {
  11.173 -			if (tulip_debug > 0)
  11.174 -				printk(KERN_WARNING "%s: no phy info, aborting mtable build\n", dev->name);
  11.175 -		        return;
  11.176 -		}
  11.177 -
  11.178 -		mtable = (struct mediatable *)
  11.179 -			kmalloc(sizeof(struct mediatable) + count*sizeof(struct medialeaf),
  11.180 -					GFP_KERNEL);
  11.181 -		if (mtable == NULL)
  11.182 -			return;				/* Horrible, impossible failure. */
  11.183 -		last_mediatable = tp->mtable = mtable;
  11.184 -		mtable->defaultmedia = media;
  11.185 -		mtable->leafcount = count;
  11.186 -		mtable->csr12dir = csr12dir;
  11.187 -		mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0;
  11.188 -		mtable->csr15dir = mtable->csr15val = 0;
  11.189 -
  11.190 -		printk(KERN_INFO "%s:  EEPROM default media type %s.\n", dev->name,
  11.191 -			   media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]);
  11.192 -		for (i = 0; i < count; i++) {
  11.193 -			struct medialeaf *leaf = &mtable->mleaf[i];
  11.194 -
  11.195 -			if ((p[0] & 0x80) == 0) { /* 21140 Compact block. */
  11.196 -				leaf->type = 0;
  11.197 -				leaf->media = p[0] & 0x3f;
  11.198 -				leaf->leafdata = p;
  11.199 -				if ((p[2] & 0x61) == 0x01)	/* Bogus, but Znyx boards do it. */
  11.200 -					mtable->has_mii = 1;
  11.201 -				p += 4;
  11.202 -			} else {
  11.203 -				leaf->type = p[1];
  11.204 -				if (p[1] == 0x05) {
  11.205 -					mtable->has_reset = i;
  11.206 -					leaf->media = p[2] & 0x0f;
  11.207 -				} else if (tp->chip_id == DM910X && p[1] == 0x80) {
  11.208 -					/* Hack to ignore Davicom delay period block */
  11.209 -					mtable->leafcount--;
  11.210 -					count--;
  11.211 -					i--;
  11.212 -					leaf->leafdata = p + 2;
  11.213 -					p += (p[0] & 0x3f) + 1;
  11.214 -					continue;
  11.215 -				} else if (p[1] & 1) {
  11.216 -					int gpr_len, reset_len;
  11.217 -
  11.218 -					mtable->has_mii = 1;
  11.219 -					leaf->media = 11;
  11.220 -					gpr_len=p[3]*2;
  11.221 -					reset_len=p[4+gpr_len]*2;
  11.222 -					new_advertise |= get_u16(&p[7+gpr_len+reset_len]);
  11.223 -				} else {
  11.224 -					mtable->has_nonmii = 1;
  11.225 -					leaf->media = p[2] & MEDIA_MASK;
  11.226 -					/* Davicom's media number for 100BaseTX is strange */
  11.227 -					if (tp->chip_id == DM910X && leaf->media == 1)
  11.228 -						leaf->media = 3;
  11.229 -					switch (leaf->media) {
  11.230 -					case 0: new_advertise |= 0x0020; break;
  11.231 -					case 4: new_advertise |= 0x0040; break;
  11.232 -					case 3: new_advertise |= 0x0080; break;
  11.233 -					case 5: new_advertise |= 0x0100; break;
  11.234 -					case 6: new_advertise |= 0x0200; break;
  11.235 -					}
  11.236 -					if (p[1] == 2  &&  leaf->media == 0) {
  11.237 -						if (p[2] & 0x40) {
  11.238 -							u32 base15 = get_unaligned((u16*)&p[7]);
  11.239 -							mtable->csr15dir =
  11.240 -								(get_unaligned((u16*)&p[9])<<16) + base15;
  11.241 -							mtable->csr15val =
  11.242 -								(get_unaligned((u16*)&p[11])<<16) + base15;
  11.243 -						} else {
  11.244 -							mtable->csr15dir = get_unaligned((u16*)&p[3])<<16;
  11.245 -							mtable->csr15val = get_unaligned((u16*)&p[5])<<16;
  11.246 -						}
  11.247 -					}
  11.248 -				}
  11.249 -				leaf->leafdata = p + 2;
  11.250 -				p += (p[0] & 0x3f) + 1;
  11.251 -			}
  11.252 -			if (tulip_debug > 1  &&  leaf->media == 11) {
  11.253 -				unsigned char *bp = leaf->leafdata;
  11.254 -				printk(KERN_INFO "%s:  MII interface PHY %d, setup/reset "
  11.255 -					   "sequences %d/%d long, capabilities %2.2x %2.2x.\n",
  11.256 -					   dev->name, bp[0], bp[1], bp[2 + bp[1]*2],
  11.257 -					   bp[5 + bp[2 + bp[1]*2]*2], bp[4 + bp[2 + bp[1]*2]*2]);
  11.258 -			}
  11.259 -			printk(KERN_INFO "%s:  Index #%d - Media %s (#%d) described "
  11.260 -				   "by a %s (%d) block.\n",
  11.261 -				   dev->name, i, medianame[leaf->media & 15], leaf->media,
  11.262 -				   leaf->type < ARRAY_SIZE(block_name) ? block_name[leaf->type] : "<unknown>",
  11.263 -				   leaf->type);
  11.264 -		}
  11.265 -		if (new_advertise)
  11.266 -			tp->sym_advertise = new_advertise;
  11.267 -	}
  11.268 -}
  11.269 -/* Reading a serial EEPROM is a "bit" grungy, but we work our way through:->.*/
  11.270 -
  11.271 -/*  EEPROM_Ctrl bits. */
  11.272 -#define EE_SHIFT_CLK	0x02	/* EEPROM shift clock. */
  11.273 -#define EE_CS			0x01	/* EEPROM chip select. */
  11.274 -#define EE_DATA_WRITE	0x04	/* Data from the Tulip to EEPROM. */
  11.275 -#define EE_WRITE_0		0x01
  11.276 -#define EE_WRITE_1		0x05
  11.277 -#define EE_DATA_READ	0x08	/* Data from the EEPROM chip. */
  11.278 -#define EE_ENB			(0x4800 | EE_CS)
  11.279 -
  11.280 -/* Delay between EEPROM clock transitions.
  11.281 -   Even at 33Mhz current PCI implementations don't overrun the EEPROM clock.
  11.282 -   We add a bus turn-around to insure that this remains true. */
  11.283 -#define eeprom_delay()	inl(ee_addr)
  11.284 -
  11.285 -/* The EEPROM commands include the alway-set leading bit. */
  11.286 -#define EE_READ_CMD		(6)
  11.287 -
  11.288 -/* Note: this routine returns extra data bits for size detection. */
  11.289 -int __devinit tulip_read_eeprom(long ioaddr, int location, int addr_len)
  11.290 -{
  11.291 -	int i;
  11.292 -	unsigned retval = 0;
  11.293 -	long ee_addr = ioaddr + CSR9;
  11.294 -	int read_cmd = location | (EE_READ_CMD << addr_len);
  11.295 -
  11.296 -	outl(EE_ENB & ~EE_CS, ee_addr);
  11.297 -	outl(EE_ENB, ee_addr);
  11.298 -
  11.299 -	/* Shift the read command bits out. */
  11.300 -	for (i = 4 + addr_len; i >= 0; i--) {
  11.301 -		short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
  11.302 -		outl(EE_ENB | dataval, ee_addr);
  11.303 -		eeprom_delay();
  11.304 -		outl(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
  11.305 -		eeprom_delay();
  11.306 -		retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
  11.307 -	}
  11.308 -	outl(EE_ENB, ee_addr);
  11.309 -	eeprom_delay();
  11.310 -
  11.311 -	for (i = 16; i > 0; i--) {
  11.312 -		outl(EE_ENB | EE_SHIFT_CLK, ee_addr);
  11.313 -		eeprom_delay();
  11.314 -		retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
  11.315 -		outl(EE_ENB, ee_addr);
  11.316 -		eeprom_delay();
  11.317 -	}
  11.318 -
  11.319 -	/* Terminate the EEPROM access. */
  11.320 -	outl(EE_ENB & ~EE_CS, ee_addr);
  11.321 -	return retval;
  11.322 -}
  11.323 -
    12.1 --- a/xen-2.4.16/drivers/net/tulip/interrupt.c	Fri Feb 14 17:11:31 2003 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,560 +0,0 @@
    12.4 -/*
    12.5 -	drivers/net/tulip/interrupt.c
    12.6 -
    12.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
    12.8 -	Copyright 2000,2001  The Linux Kernel Team
    12.9 -	Written/copyright 1994-2001 by Donald Becker.
   12.10 -
   12.11 -	This software may be used and distributed according to the terms
   12.12 -	of the GNU General Public License, incorporated herein by reference.
   12.13 -
   12.14 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   12.15 -	for more information on this driver, or visit the project
   12.16 -	Web page at http://sourceforge.net/projects/tulip/
   12.17 -
   12.18 -*/
   12.19 -
   12.20 -#include "tulip.h"
   12.21 -#include <linux/config.h>
   12.22 -#include <linux/etherdevice.h>
   12.23 -#include <linux/pci.h>
   12.24 -
   12.25 -
   12.26 -int tulip_rx_copybreak;
   12.27 -unsigned int tulip_max_interrupt_work;
   12.28 -
   12.29 -#ifdef CONFIG_NET_HW_FLOWCONTROL
   12.30 -
   12.31 -#define MIT_SIZE 15
   12.32 -unsigned int mit_table[MIT_SIZE+1] =
   12.33 -{
   12.34 -        /*  CRS11 21143 hardware Mitigation Control Interrupt
   12.35 -            We use only RX mitigation we other techniques for
   12.36 -            TX intr. mitigation.
   12.37 -
   12.38 -           31    Cycle Size (timer control)
   12.39 -           30:27 TX timer in 16 * Cycle size
   12.40 -           26:24 TX No pkts before Int.
   12.41 -           23:20 RX timer in Cycle size
   12.42 -           19:17 RX No pkts before Int.
   12.43 -           16       Continues Mode (CM)
   12.44 -        */
   12.45 -
   12.46 -        0x0,             /* IM disabled */
   12.47 -        0x80150000,      /* RX time = 1, RX pkts = 2, CM = 1 */
   12.48 -        0x80150000,
   12.49 -        0x80270000,
   12.50 -        0x80370000,
   12.51 -        0x80490000,
   12.52 -        0x80590000,
   12.53 -        0x80690000,
   12.54 -        0x807B0000,
   12.55 -        0x808B0000,
   12.56 -        0x809D0000,
   12.57 -        0x80AD0000,
   12.58 -        0x80BD0000,
   12.59 -        0x80CF0000,
   12.60 -        0x80DF0000,
   12.61 -//       0x80FF0000      /* RX time = 16, RX pkts = 7, CM = 1 */
   12.62 -        0x80F10000      /* RX time = 16, RX pkts = 0, CM = 1 */
   12.63 -};
   12.64 -#endif
   12.65 -
   12.66 -
   12.67 -int tulip_refill_rx(struct net_device *dev)
   12.68 -{
   12.69 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   12.70 -	int entry;
   12.71 -	int refilled = 0;
   12.72 -
   12.73 -	/* Refill the Rx ring buffers. */
   12.74 -	for (; tp->cur_rx - tp->dirty_rx > 0; tp->dirty_rx++) {
   12.75 -		entry = tp->dirty_rx % RX_RING_SIZE;
   12.76 -		if (tp->rx_buffers[entry].skb == NULL) {
   12.77 -			struct sk_buff *skb;
   12.78 -			dma_addr_t mapping;
   12.79 -
   12.80 -			skb = tp->rx_buffers[entry].skb = dev_alloc_skb(PKT_BUF_SZ);
   12.81 -			if (skb == NULL)
   12.82 -				break;
   12.83 -
   12.84 -			mapping = pci_map_single(tp->pdev, skb->tail, PKT_BUF_SZ,
   12.85 -						 PCI_DMA_FROMDEVICE);
   12.86 -			tp->rx_buffers[entry].mapping = mapping;
   12.87 -
   12.88 -			skb->dev = dev;			/* Mark as being used by this device. */
   12.89 -			tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping);
   12.90 -			refilled++;
   12.91 -		}
   12.92 -		tp->rx_ring[entry].status = cpu_to_le32(DescOwned);
   12.93 -	}
   12.94 -	if(tp->chip_id == LC82C168) {
   12.95 -		if(((inl(dev->base_addr + CSR5)>>17)&0x07) == 4) {
   12.96 -			/* Rx stopped due to out of buffers,
   12.97 -			 * restart it
   12.98 -			 */
   12.99 -			outl(0x01, dev->base_addr + CSR2);
  12.100 -		}
  12.101 -	}
  12.102 -	return refilled;
  12.103 -}
  12.104 -
  12.105 -
  12.106 -static int tulip_rx(struct net_device *dev)
  12.107 -{
  12.108 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  12.109 -	int entry = tp->cur_rx % RX_RING_SIZE;
  12.110 -	int rx_work_limit = tp->dirty_rx + RX_RING_SIZE - tp->cur_rx;
  12.111 -	int received = 0;
  12.112 -
  12.113 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.114 -        int drop = 0, mit_sel = 0;
  12.115 -
  12.116 -/* that one buffer is needed for mit activation; or might be a
  12.117 -   bug in the ring buffer code; check later -- JHS*/
  12.118 -
  12.119 -        if (rx_work_limit >=RX_RING_SIZE) rx_work_limit--;
  12.120 -#endif
  12.121 -
  12.122 -	if (tulip_debug > 4)
  12.123 -		printk(KERN_DEBUG " In tulip_rx(), entry %d %8.8x.\n", entry,
  12.124 -			   tp->rx_ring[entry].status);
  12.125 -	/* If we own the next entry, it is a new packet. Send it up. */
  12.126 -	while ( ! (tp->rx_ring[entry].status & cpu_to_le32(DescOwned))) {
  12.127 -		s32 status = le32_to_cpu(tp->rx_ring[entry].status);
  12.128 -
  12.129 -		if (tulip_debug > 5)
  12.130 -			printk(KERN_DEBUG "%s: In tulip_rx(), entry %d %8.8x.\n",
  12.131 -				   dev->name, entry, status);
  12.132 -		if (--rx_work_limit < 0)
  12.133 -			break;
  12.134 -		if ((status & 0x38008300) != 0x0300) {
  12.135 -			if ((status & 0x38000300) != 0x0300) {
  12.136 -				/* Ingore earlier buffers. */
  12.137 -				if ((status & 0xffff) != 0x7fff) {
  12.138 -					if (tulip_debug > 1)
  12.139 -						printk(KERN_WARNING "%s: Oversized Ethernet frame "
  12.140 -							   "spanned multiple buffers, status %8.8x!\n",
  12.141 -							   dev->name, status);
  12.142 -					tp->stats.rx_length_errors++;
  12.143 -				}
  12.144 -			} else if (status & RxDescFatalErr) {
  12.145 -				/* There was a fatal error. */
  12.146 -				if (tulip_debug > 2)
  12.147 -					printk(KERN_DEBUG "%s: Receive error, Rx status %8.8x.\n",
  12.148 -						   dev->name, status);
  12.149 -				tp->stats.rx_errors++; /* end of a packet.*/
  12.150 -				if (status & 0x0890) tp->stats.rx_length_errors++;
  12.151 -				if (status & 0x0004) tp->stats.rx_frame_errors++;
  12.152 -				if (status & 0x0002) tp->stats.rx_crc_errors++;
  12.153 -				if (status & 0x0001) tp->stats.rx_fifo_errors++;
  12.154 -			}
  12.155 -		} else {
  12.156 -			/* Omit the four octet CRC from the length. */
  12.157 -			short pkt_len = ((status >> 16) & 0x7ff) - 4;
  12.158 -			struct sk_buff *skb;
  12.159 -
  12.160 -#ifndef final_version
  12.161 -			if (pkt_len > 1518) {
  12.162 -				printk(KERN_WARNING "%s: Bogus packet size of %d (%#x).\n",
  12.163 -					   dev->name, pkt_len, pkt_len);
  12.164 -				pkt_len = 1518;
  12.165 -				tp->stats.rx_length_errors++;
  12.166 -			}
  12.167 -#endif
  12.168 -
  12.169 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.170 -                        drop = atomic_read(&netdev_dropping);
  12.171 -                        if (drop)
  12.172 -                                goto throttle;
  12.173 -#endif
  12.174 -			/* Check if the packet is long enough to accept without copying
  12.175 -			   to a minimally-sized skbuff. */
  12.176 -			if (pkt_len < tulip_rx_copybreak
  12.177 -				&& (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
  12.178 -                        //if (0) {
  12.179 -				skb->dev = dev;
  12.180 -				skb_reserve(skb, 2);	/* 16 byte align the IP header */
  12.181 -				pci_dma_sync_single(tp->pdev,
  12.182 -						    tp->rx_buffers[entry].mapping,
  12.183 -						    pkt_len, PCI_DMA_FROMDEVICE);
  12.184 -#if ! defined(__alpha__)
  12.185 -				eth_copy_and_sum(skb, tp->rx_buffers[entry].skb->tail,
  12.186 -						 pkt_len, 0);
  12.187 -				skb_put(skb, pkt_len);
  12.188 -#else
  12.189 -				memcpy(skb_put(skb, pkt_len),
  12.190 -				       tp->rx_buffers[entry].skb->tail,
  12.191 -				       pkt_len);
  12.192 -#endif
  12.193 -			} else { 	/* Pass up the skb already on the Rx ring. */
  12.194 -				char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
  12.195 -						     pkt_len);
  12.196 -
  12.197 -#ifndef final_version
  12.198 -				if (tp->rx_buffers[entry].mapping !=
  12.199 -				    le32_to_cpu(tp->rx_ring[entry].buffer1)) {
  12.200 -					printk(KERN_ERR "%s: Internal fault: The skbuff addresses "
  12.201 -					       "do not match in tulip_rx: %08x vs. %08x %p / %p.\n",
  12.202 -					       dev->name,
  12.203 -					       le32_to_cpu(tp->rx_ring[entry].buffer1),
  12.204 -					       tp->rx_buffers[entry].mapping,
  12.205 -					       skb->head, temp);
  12.206 -				}
  12.207 -#endif
  12.208 -
  12.209 -				pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
  12.210 -						 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
  12.211 -
  12.212 -				tp->rx_buffers[entry].skb = NULL;
  12.213 -				tp->rx_buffers[entry].mapping = 0;
  12.214 -			}
  12.215 -			skb->protocol = eth_type_trans(skb, dev);
  12.216 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.217 -                        mit_sel =
  12.218 -#endif
  12.219 -			netif_rx(skb);
  12.220 -
  12.221 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.222 -                        switch (mit_sel) {
  12.223 -                        case NET_RX_SUCCESS:
  12.224 -                        case NET_RX_CN_LOW:
  12.225 -                        case NET_RX_CN_MOD:
  12.226 -                                break;
  12.227 -
  12.228 -                        case NET_RX_CN_HIGH:
  12.229 -                                rx_work_limit -= NET_RX_CN_HIGH; /* additional*/
  12.230 -                                break;
  12.231 -                        case NET_RX_DROP:
  12.232 -                                rx_work_limit = -1;
  12.233 -                                break;
  12.234 -                        default:
  12.235 -                                printk("unknown feedback return code %d\n", mit_sel);
  12.236 -                                break;
  12.237 -                        }
  12.238 -
  12.239 -                        drop = atomic_read(&netdev_dropping);
  12.240 -                        if (drop) {
  12.241 -throttle:
  12.242 -                                rx_work_limit = -1;
  12.243 -                                mit_sel = NET_RX_DROP;
  12.244 -
  12.245 -                                if (tp->fc_bit) {
  12.246 -                                        long ioaddr = dev->base_addr;
  12.247 -
  12.248 -                                        /* disable Rx & RxNoBuf ints. */
  12.249 -                                        outl(tulip_tbl[tp->chip_id].valid_intrs&RX_A_NBF_STOP, ioaddr + CSR7);
  12.250 -                                        set_bit(tp->fc_bit, &netdev_fc_xoff);
  12.251 -                                }
  12.252 -                        }
  12.253 -#endif
  12.254 -			dev->last_rx = jiffies;
  12.255 -			tp->stats.rx_packets++;
  12.256 -			tp->stats.rx_bytes += pkt_len;
  12.257 -		}
  12.258 -		received++;
  12.259 -		entry = (++tp->cur_rx) % RX_RING_SIZE;
  12.260 -	}
  12.261 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.262 -
  12.263 -        /* We use this simplistic scheme for IM. It's proven by
  12.264 -           real life installations. We can have IM enabled
  12.265 -           continuesly but this would cause unnecessary latency.
  12.266 -           Unfortunely we can't use all the NET_RX_* feedback here.
  12.267 -           This would turn on IM for devices that is not contributing
  12.268 -           to backlog congestion with unnecessary latency.
  12.269 -
  12.270 -           We monitor the the device RX-ring and have:
  12.271 -
  12.272 -           HW Interrupt Mitigation either ON or OFF.
  12.273 -
  12.274 -           ON:  More then 1 pkt received (per intr.) OR we are dropping
  12.275 -           OFF: Only 1 pkt received
  12.276 -
  12.277 -           Note. We only use min and max (0, 15) settings from mit_table */
  12.278 -
  12.279 -
  12.280 -        if( tp->flags &  HAS_INTR_MITIGATION) {
  12.281 -                if((received > 1 || mit_sel == NET_RX_DROP)
  12.282 -                   && tp->mit_sel != 15 ) {
  12.283 -                        tp->mit_sel = 15;
  12.284 -                        tp->mit_change = 1; /* Force IM change */
  12.285 -                }
  12.286 -                if((received <= 1 && mit_sel != NET_RX_DROP) && tp->mit_sel != 0 ) {
  12.287 -                        tp->mit_sel = 0;
  12.288 -                        tp->mit_change = 1; /* Force IM change */
  12.289 -                }
  12.290 -        }
  12.291 -
  12.292 -        return RX_RING_SIZE+1; /* maxrx+1 */
  12.293 -#else
  12.294 -	return received;
  12.295 -#endif
  12.296 -}
  12.297 -
  12.298 -
  12.299 -/* The interrupt handler does all of the Rx thread work and cleans up
  12.300 -   after the Tx thread. */
  12.301 -void tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
  12.302 -{
  12.303 -	struct net_device *dev = (struct net_device *)dev_instance;
  12.304 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  12.305 -	long ioaddr = dev->base_addr;
  12.306 -	int csr5;
  12.307 -	int entry;
  12.308 -	int missed;
  12.309 -	int rx = 0;
  12.310 -	int tx = 0;
  12.311 -	int oi = 0;
  12.312 -	int maxrx = RX_RING_SIZE;
  12.313 -	int maxtx = TX_RING_SIZE;
  12.314 -	int maxoi = TX_RING_SIZE;
  12.315 -	unsigned int work_count = tulip_max_interrupt_work;
  12.316 -
  12.317 -	/* Let's see whether the interrupt really is for us */
  12.318 -	csr5 = inl(ioaddr + CSR5);
  12.319 -
  12.320 -	if ((csr5 & (NormalIntr|AbnormalIntr)) == 0)
  12.321 -		return;
  12.322 -
  12.323 -	tp->nir++;
  12.324 -
  12.325 -	do {
  12.326 -		/* Acknowledge all of the current interrupt sources ASAP. */
  12.327 -		outl(csr5 & 0x0001ffff, ioaddr + CSR5);
  12.328 -
  12.329 -		if (tulip_debug > 4)
  12.330 -			printk(KERN_DEBUG "%s: interrupt  csr5=%#8.8x new csr5=%#8.8x.\n",
  12.331 -				   dev->name, csr5, inl(dev->base_addr + CSR5));
  12.332 -
  12.333 -		if (csr5 & (RxIntr | RxNoBuf)) {
  12.334 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.335 -                        if ((!tp->fc_bit) ||
  12.336 -			    (!test_bit(tp->fc_bit, &netdev_fc_xoff)))
  12.337 -#endif
  12.338 -				rx += tulip_rx(dev);
  12.339 -			tulip_refill_rx(dev);
  12.340 -		}
  12.341 -
  12.342 -		if (csr5 & (TxNoBuf | TxDied | TxIntr | TimerInt)) {
  12.343 -			unsigned int dirty_tx;
  12.344 -
  12.345 -			spin_lock(&tp->lock);
  12.346 -
  12.347 -			for (dirty_tx = tp->dirty_tx; tp->cur_tx - dirty_tx > 0;
  12.348 -				 dirty_tx++) {
  12.349 -				int entry = dirty_tx % TX_RING_SIZE;
  12.350 -				int status = le32_to_cpu(tp->tx_ring[entry].status);
  12.351 -
  12.352 -				if (status < 0)
  12.353 -					break;			/* It still has not been Txed */
  12.354 -
  12.355 -				/* Check for Rx filter setup frames. */
  12.356 -				if (tp->tx_buffers[entry].skb == NULL) {
  12.357 -					/* test because dummy frames not mapped */
  12.358 -					if (tp->tx_buffers[entry].mapping)
  12.359 -						pci_unmap_single(tp->pdev,
  12.360 -							 tp->tx_buffers[entry].mapping,
  12.361 -							 sizeof(tp->setup_frame),
  12.362 -							 PCI_DMA_TODEVICE);
  12.363 -					continue;
  12.364 -				}
  12.365 -
  12.366 -				if (status & 0x8000) {
  12.367 -					/* There was an major error, log it. */
  12.368 -#ifndef final_version
  12.369 -					if (tulip_debug > 1)
  12.370 -						printk(KERN_DEBUG "%s: Transmit error, Tx status %8.8x.\n",
  12.371 -							   dev->name, status);
  12.372 -#endif
  12.373 -					tp->stats.tx_errors++;
  12.374 -					if (status & 0x4104) tp->stats.tx_aborted_errors++;
  12.375 -					if (status & 0x0C00) tp->stats.tx_carrier_errors++;
  12.376 -					if (status & 0x0200) tp->stats.tx_window_errors++;
  12.377 -					if (status & 0x0002) tp->stats.tx_fifo_errors++;
  12.378 -					if ((status & 0x0080) && tp->full_duplex == 0)
  12.379 -						tp->stats.tx_heartbeat_errors++;
  12.380 -				} else {
  12.381 -					tp->stats.tx_bytes +=
  12.382 -						tp->tx_buffers[entry].skb->len;
  12.383 -					tp->stats.collisions += (status >> 3) & 15;
  12.384 -					tp->stats.tx_packets++;
  12.385 -				}
  12.386 -
  12.387 -				pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
  12.388 -						 tp->tx_buffers[entry].skb->len,
  12.389 -						 PCI_DMA_TODEVICE);
  12.390 -
  12.391 -				/* Free the original skb. */
  12.392 -				dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
  12.393 -				tp->tx_buffers[entry].skb = NULL;
  12.394 -				tp->tx_buffers[entry].mapping = 0;
  12.395 -				tx++;
  12.396 -			}
  12.397 -
  12.398 -#ifndef final_version
  12.399 -			if (tp->cur_tx - dirty_tx > TX_RING_SIZE) {
  12.400 -				printk(KERN_ERR "%s: Out-of-sync dirty pointer, %d vs. %d.\n",
  12.401 -					   dev->name, dirty_tx, tp->cur_tx);
  12.402 -				dirty_tx += TX_RING_SIZE;
  12.403 -			}
  12.404 -#endif
  12.405 -
  12.406 -			if (tp->cur_tx - dirty_tx < TX_RING_SIZE - 2)
  12.407 -				netif_wake_queue(dev);
  12.408 -
  12.409 -			tp->dirty_tx = dirty_tx;
  12.410 -			if (csr5 & TxDied) {
  12.411 -				if (tulip_debug > 2)
  12.412 -					printk(KERN_WARNING "%s: The transmitter stopped."
  12.413 -						   "  CSR5 is %x, CSR6 %x, new CSR6 %x.\n",
  12.414 -						   dev->name, csr5, inl(ioaddr + CSR6), tp->csr6);
  12.415 -				tulip_restart_rxtx(tp);
  12.416 -			}
  12.417 -			spin_unlock(&tp->lock);
  12.418 -		}
  12.419 -
  12.420 -		/* Log errors. */
  12.421 -		if (csr5 & AbnormalIntr) {	/* Abnormal error summary bit. */
  12.422 -			if (csr5 == 0xffffffff)
  12.423 -				break;
  12.424 -			if (csr5 & TxJabber) tp->stats.tx_errors++;
  12.425 -			if (csr5 & TxFIFOUnderflow) {
  12.426 -				if ((tp->csr6 & 0xC000) != 0xC000)
  12.427 -					tp->csr6 += 0x4000;	/* Bump up the Tx threshold */
  12.428 -				else
  12.429 -					tp->csr6 |= 0x00200000;  /* Store-n-forward. */
  12.430 -				/* Restart the transmit process. */
  12.431 -				tulip_restart_rxtx(tp);
  12.432 -				outl(0, ioaddr + CSR1);
  12.433 -			}
  12.434 -			if (csr5 & (RxDied | RxNoBuf)) {
  12.435 -				if (tp->flags & COMET_MAC_ADDR) {
  12.436 -					outl(tp->mc_filter[0], ioaddr + 0xAC);
  12.437 -					outl(tp->mc_filter[1], ioaddr + 0xB0);
  12.438 -				}
  12.439 -			}
  12.440 -			if (csr5 & RxDied) {		/* Missed a Rx frame. */
  12.441 -                                tp->stats.rx_missed_errors += inl(ioaddr + CSR8) & 0xffff;
  12.442 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.443 -				if (tp->fc_bit && !test_bit(tp->fc_bit, &netdev_fc_xoff)) {
  12.444 -					tp->stats.rx_errors++;
  12.445 -					tulip_start_rxtx(tp);
  12.446 -				}
  12.447 -#else
  12.448 -				tp->stats.rx_errors++;
  12.449 -				tulip_start_rxtx(tp);
  12.450 -#endif
  12.451 -			}
  12.452 -			/*
  12.453 -			 * NB: t21142_lnk_change() does a del_timer_sync(), so be careful if this
  12.454 -			 * call is ever done under the spinlock
  12.455 -			 */
  12.456 -			if (csr5 & (TPLnkPass | TPLnkFail | 0x08000000)) {
  12.457 -				if (tp->link_change)
  12.458 -					(tp->link_change)(dev, csr5);
  12.459 -			}
  12.460 -			if (csr5 & SytemError) {
  12.461 -				int error = (csr5 >> 23) & 7;
  12.462 -				/* oops, we hit a PCI error.  The code produced corresponds
  12.463 -				 * to the reason:
  12.464 -				 *  0 - parity error
  12.465 -				 *  1 - master abort
  12.466 -				 *  2 - target abort
  12.467 -				 * Note that on parity error, we should do a software reset
  12.468 -				 * of the chip to get it back into a sane state (according
  12.469 -				 * to the 21142/3 docs that is).
  12.470 -				 *   -- rmk
  12.471 -				 */
  12.472 -				printk(KERN_ERR "%s: (%lu) System Error occured (%d)\n",
  12.473 -					dev->name, tp->nir, error);
  12.474 -			}
  12.475 -			/* Clear all error sources, included undocumented ones! */
  12.476 -			outl(0x0800f7ba, ioaddr + CSR5);
  12.477 -			oi++;
  12.478 -		}
  12.479 -		if (csr5 & TimerInt) {
  12.480 -
  12.481 -			if (tulip_debug > 2)
  12.482 -				printk(KERN_ERR "%s: Re-enabling interrupts, %8.8x.\n",
  12.483 -					   dev->name, csr5);
  12.484 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.485 -                        if (tp->fc_bit && (test_bit(tp->fc_bit, &netdev_fc_xoff)))
  12.486 -                          if (net_ratelimit()) printk("BUG!! enabling interupt when FC off (timerintr.) \n");
  12.487 -#endif
  12.488 -			outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
  12.489 -			tp->ttimer = 0;
  12.490 -			oi++;
  12.491 -		}
  12.492 -		if (tx > maxtx || rx > maxrx || oi > maxoi) {
  12.493 -			if (tulip_debug > 1)
  12.494 -				printk(KERN_WARNING "%s: Too much work during an interrupt, "
  12.495 -					   "csr5=0x%8.8x. (%lu) (%d,%d,%d)\n", dev->name, csr5, tp->nir, tx, rx, oi);
  12.496 -
  12.497 -                       /* Acknowledge all interrupt sources. */
  12.498 -                        outl(0x8001ffff, ioaddr + CSR5);
  12.499 -                        if (tp->flags & HAS_INTR_MITIGATION) {
  12.500 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  12.501 -                                if(tp->mit_change) {
  12.502 -                                        outl(mit_table[tp->mit_sel], ioaddr + CSR11);
  12.503 -                                        tp->mit_change = 0;
  12.504 -                                }
  12.505 -#else
  12.506 -                     /* Josip Loncaric at ICASE did extensive experimentation
  12.507 -			to develop a good interrupt mitigation setting.*/
  12.508 -                                outl(0x8b240000, ioaddr + CSR11);
  12.509 -#endif
  12.510 -                        } else if (tp->chip_id == LC82C168) {
  12.511 -				/* the LC82C168 doesn't have a hw timer.*/
  12.512 -				outl(0x00, ioaddr + CSR7);
  12.513 -				mod_timer(&tp->timer, RUN_AT(HZ/50));
  12.514 -			} else {
  12.515 -                          /* Mask all interrupting sources, set timer to
  12.516 -				re-enable. */
  12.517 -#ifndef CONFIG_NET_HW_FLOWCONTROL
  12.518 -                                outl(((~csr5) & 0x0001ebef) | AbnormalIntr | TimerInt, ioaddr + CSR7);
  12.519 -                                outl(0x0012, ioaddr + CSR11);
  12.520 -#endif
  12.521 -                        }
  12.522 -			break;
  12.523 -		}
  12.524 -
  12.525 -		work_count--;
  12.526 -		if (work_count == 0)
  12.527 -			break;
  12.528 -
  12.529 -		csr5 = inl(ioaddr + CSR5);
  12.530 -	} while ((csr5 & (NormalIntr|AbnormalIntr)) != 0);
  12.531 -
  12.532 -	tulip_refill_rx(dev);
  12.533 -
  12.534 -	/* check if the card is in suspend mode */
  12.535 -	entry = tp->dirty_rx % RX_RING_SIZE;
  12.536 -	if (tp->rx_buffers[entry].skb == NULL) {
  12.537 -		if (tulip_debug > 1)
  12.538 -			printk(KERN_WARNING "%s: in rx suspend mode: (%lu) (tp->cur_rx = %u, ttimer = %d, rx = %d) go/stay in suspend mode\n", dev->name, tp->nir, tp->cur_rx, tp->ttimer, rx);
  12.539 -		if (tp->chip_id == LC82C168) {
  12.540 -			outl(0x00, ioaddr + CSR7);
  12.541 -			mod_timer(&tp->timer, RUN_AT(HZ/50));
  12.542 -		} else {
  12.543 -			if (tp->ttimer == 0 || (inl(ioaddr + CSR11) & 0xffff) == 0) {
  12.544 -				if (tulip_debug > 1)
  12.545 -					printk(KERN_WARNING "%s: in rx suspend mode: (%lu) set timer\n", dev->name, tp->nir);
  12.546 -				outl(tulip_tbl[tp->chip_id].valid_intrs | TimerInt,
  12.547 -					ioaddr + CSR7);
  12.548 -				outl(TimerInt, ioaddr + CSR5);
  12.549 -				outl(12, ioaddr + CSR11);
  12.550 -				tp->ttimer = 1;
  12.551 -			}
  12.552 -		}
  12.553 -	}
  12.554 -
  12.555 -	if ((missed = inl(ioaddr + CSR8) & 0x1ffff)) {
  12.556 -		tp->stats.rx_dropped += missed & 0x10000 ? 0x10000 : missed;
  12.557 -	}
  12.558 -
  12.559 -	if (tulip_debug > 4)
  12.560 -		printk(KERN_DEBUG "%s: exiting interrupt, csr5=%#4.4x.\n",
  12.561 -			   dev->name, inl(ioaddr + CSR5));
  12.562 -
  12.563 -}
    13.1 --- a/xen-2.4.16/drivers/net/tulip/media.c	Fri Feb 14 17:11:31 2003 +0000
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,563 +0,0 @@
    13.4 -/*
    13.5 -	drivers/net/tulip/media.c
    13.6 -
    13.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
    13.8 -	Copyright 2000,2001  The Linux Kernel Team
    13.9 -	Written/copyright 1994-2001 by Donald Becker.
   13.10 -
   13.11 -	This software may be used and distributed according to the terms
   13.12 -	of the GNU General Public License, incorporated herein by reference.
   13.13 -
   13.14 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   13.15 -	for more information on this driver, or visit the project
   13.16 -	Web page at http://sourceforge.net/projects/tulip/
   13.17 -
   13.18 -*/
   13.19 -
   13.20 -//#include <linux/kernel.h>
   13.21 -#include <linux/mii.h>
   13.22 -#include <linux/init.h>
   13.23 -#include <linux/delay.h>
   13.24 -#include "tulip.h"
   13.25 -
   13.26 -
   13.27 -/* This is a mysterious value that can be written to CSR11 in the 21040 (only)
   13.28 -   to support a pre-NWay full-duplex signaling mechanism using short frames.
   13.29 -   No one knows what it should be, but if left at its default value some
   13.30 -   10base2(!) packets trigger a full-duplex-request interrupt. */
   13.31 -#define FULL_DUPLEX_MAGIC	0x6969
   13.32 -
   13.33 -/* The maximum data clock rate is 2.5 Mhz.  The minimum timing is usually
   13.34 -   met by back-to-back PCI I/O cycles, but we insert a delay to avoid
   13.35 -   "overclocking" issues or future 66Mhz PCI. */
   13.36 -#define mdio_delay() inl(mdio_addr)
   13.37 -
   13.38 -/* Read and write the MII registers using software-generated serial
   13.39 -   MDIO protocol.  It is just different enough from the EEPROM protocol
   13.40 -   to not share code.  The maxium data clock rate is 2.5 Mhz. */
   13.41 -#define MDIO_SHIFT_CLK		0x10000
   13.42 -#define MDIO_DATA_WRITE0	0x00000
   13.43 -#define MDIO_DATA_WRITE1	0x20000
   13.44 -#define MDIO_ENB		0x00000 /* Ignore the 0x02000 databook setting. */
   13.45 -#define MDIO_ENB_IN		0x40000
   13.46 -#define MDIO_DATA_READ		0x80000
   13.47 -
   13.48 -static const unsigned char comet_miireg2offset[32] = {
   13.49 -	0xB4, 0xB8, 0xBC, 0xC0,  0xC4, 0xC8, 0xCC, 0,  0,0,0,0,  0,0,0,0,
   13.50 -	0,0xD0,0,0,  0,0,0,0,  0,0,0,0, 0, 0xD4, 0xD8, 0xDC, };
   13.51 -
   13.52 -
   13.53 -/* MII transceiver control section.
   13.54 -   Read and write the MII registers using software-generated serial
   13.55 -   MDIO protocol.  See the MII specifications or DP83840A data sheet
   13.56 -   for details. */
   13.57 -
   13.58 -int tulip_mdio_read(struct net_device *dev, int phy_id, int location)
   13.59 -{
   13.60 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   13.61 -	int i;
   13.62 -	int read_cmd = (0xf6 << 10) | ((phy_id & 0x1f) << 5) | location;
   13.63 -	int retval = 0;
   13.64 -	long ioaddr = dev->base_addr;
   13.65 -	long mdio_addr = ioaddr + CSR9;
   13.66 -	unsigned long flags;
   13.67 -
   13.68 -	if (location & ~0x1f)
   13.69 -		return 0xffff;
   13.70 -
   13.71 -	if (tp->chip_id == COMET  &&  phy_id == 30) {
   13.72 -		if (comet_miireg2offset[location])
   13.73 -			return inl(ioaddr + comet_miireg2offset[location]);
   13.74 -		return 0xffff;
   13.75 -	}
   13.76 -
   13.77 -	spin_lock_irqsave(&tp->mii_lock, flags);
   13.78 -	if (tp->chip_id == LC82C168) {
   13.79 -		int i = 1000;
   13.80 -		outl(0x60020000 + (phy_id<<23) + (location<<18), ioaddr + 0xA0);
   13.81 -		inl(ioaddr + 0xA0);
   13.82 -		inl(ioaddr + 0xA0);
   13.83 -		while (--i > 0) {
   13.84 -			barrier();
   13.85 -			if ( ! ((retval = inl(ioaddr + 0xA0)) & 0x80000000))
   13.86 -				break;
   13.87 -		}
   13.88 -		spin_unlock_irqrestore(&tp->mii_lock, flags);
   13.89 -		return retval & 0xffff;
   13.90 -	}
   13.91 -
   13.92 -	/* Establish sync by sending at least 32 logic ones. */
   13.93 -	for (i = 32; i >= 0; i--) {
   13.94 -		outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
   13.95 -		mdio_delay();
   13.96 -		outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
   13.97 -		mdio_delay();
   13.98 -	}
   13.99 -	/* Shift the read command bits out. */
  13.100 -	for (i = 15; i >= 0; i--) {
  13.101 -		int dataval = (read_cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
  13.102 -
  13.103 -		outl(MDIO_ENB | dataval, mdio_addr);
  13.104 -		mdio_delay();
  13.105 -		outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
  13.106 -		mdio_delay();
  13.107 -	}
  13.108 -	/* Read the two transition, 16 data, and wire-idle bits. */
  13.109 -	for (i = 19; i > 0; i--) {
  13.110 -		outl(MDIO_ENB_IN, mdio_addr);
  13.111 -		mdio_delay();
  13.112 -		retval = (retval << 1) | ((inl(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
  13.113 -		outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
  13.114 -		mdio_delay();
  13.115 -	}
  13.116 -
  13.117 -	spin_unlock_irqrestore(&tp->mii_lock, flags);
  13.118 -	return (retval>>1) & 0xffff;
  13.119 -}
  13.120 -
  13.121 -void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int val)
  13.122 -{
  13.123 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  13.124 -	int i;
  13.125 -	int cmd = (0x5002 << 16) | ((phy_id & 0x1f) << 23) | (location<<18) | (val & 0xffff);
  13.126 -	long ioaddr = dev->base_addr;
  13.127 -	long mdio_addr = ioaddr + CSR9;
  13.128 -	unsigned long flags;
  13.129 -
  13.130 -	if (location & ~0x1f)
  13.131 -		return;
  13.132 -
  13.133 -	if (tp->chip_id == COMET && phy_id == 30) {
  13.134 -		if (comet_miireg2offset[location])
  13.135 -			outl(val, ioaddr + comet_miireg2offset[location]);
  13.136 -		return;
  13.137 -	}
  13.138 -
  13.139 -	spin_lock_irqsave(&tp->mii_lock, flags);
  13.140 -	if (tp->chip_id == LC82C168) {
  13.141 -		int i = 1000;
  13.142 -		outl(cmd, ioaddr + 0xA0);
  13.143 -		do {
  13.144 -			barrier();
  13.145 -			if ( ! (inl(ioaddr + 0xA0) & 0x80000000))
  13.146 -				break;
  13.147 -		} while (--i > 0);
  13.148 -		spin_unlock_irqrestore(&tp->mii_lock, flags);
  13.149 -		return;
  13.150 -	}
  13.151 -
  13.152 -	/* Establish sync by sending 32 logic ones. */
  13.153 -	for (i = 32; i >= 0; i--) {
  13.154 -		outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
  13.155 -		mdio_delay();
  13.156 -		outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
  13.157 -		mdio_delay();
  13.158 -	}
  13.159 -	/* Shift the command bits out. */
  13.160 -	for (i = 31; i >= 0; i--) {
  13.161 -		int dataval = (cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
  13.162 -		outl(MDIO_ENB | dataval, mdio_addr);
  13.163 -		mdio_delay();
  13.164 -		outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
  13.165 -		mdio_delay();
  13.166 -	}
  13.167 -	/* Clear out extra bits. */
  13.168 -	for (i = 2; i > 0; i--) {
  13.169 -		outl(MDIO_ENB_IN, mdio_addr);
  13.170 -		mdio_delay();
  13.171 -		outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
  13.172 -		mdio_delay();
  13.173 -	}
  13.174 -
  13.175 -	spin_unlock_irqrestore(&tp->mii_lock, flags);
  13.176 -}
  13.177 -
  13.178 -
  13.179 -/* Set up the transceiver control registers for the selected media type. */
  13.180 -void tulip_select_media(struct net_device *dev, int startup)
  13.181 -{
  13.182 -	long ioaddr = dev->base_addr;
  13.183 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  13.184 -	struct mediatable *mtable = tp->mtable;
  13.185 -	u32 new_csr6;
  13.186 -	int i;
  13.187 -
  13.188 -	if (mtable) {
  13.189 -		struct medialeaf *mleaf = &mtable->mleaf[tp->cur_index];
  13.190 -		unsigned char *p = mleaf->leafdata;
  13.191 -		switch (mleaf->type) {
  13.192 -		case 0:					/* 21140 non-MII xcvr. */
  13.193 -			if (tulip_debug > 1)
  13.194 -				printk(KERN_DEBUG "%s: Using a 21140 non-MII transceiver"
  13.195 -					   " with control setting %2.2x.\n",
  13.196 -					   dev->name, p[1]);
  13.197 -			dev->if_port = p[0];
  13.198 -			if (startup)
  13.199 -				outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
  13.200 -			outl(p[1], ioaddr + CSR12);
  13.201 -			new_csr6 = 0x02000000 | ((p[2] & 0x71) << 18);
  13.202 -			break;
  13.203 -		case 2: case 4: {
  13.204 -			u16 setup[5];
  13.205 -			u32 csr13val, csr14val, csr15dir, csr15val;
  13.206 -			for (i = 0; i < 5; i++)
  13.207 -				setup[i] = get_u16(&p[i*2 + 1]);
  13.208 -
  13.209 -			dev->if_port = p[0] & MEDIA_MASK;
  13.210 -			if (tulip_media_cap[dev->if_port] & MediaAlwaysFD)
  13.211 -				tp->full_duplex = 1;
  13.212 -
  13.213 -			if (startup && mtable->has_reset) {
  13.214 -				struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
  13.215 -				unsigned char *rst = rleaf->leafdata;
  13.216 -				if (tulip_debug > 1)
  13.217 -					printk(KERN_DEBUG "%s: Resetting the transceiver.\n",
  13.218 -						   dev->name);
  13.219 -				for (i = 0; i < rst[0]; i++)
  13.220 -					outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
  13.221 -			}
  13.222 -			if (tulip_debug > 1)
  13.223 -				printk(KERN_DEBUG "%s: 21143 non-MII %s transceiver control "
  13.224 -					   "%4.4x/%4.4x.\n",
  13.225 -					   dev->name, medianame[dev->if_port], setup[0], setup[1]);
  13.226 -			if (p[0] & 0x40) {	/* SIA (CSR13-15) setup values are provided. */
  13.227 -				csr13val = setup[0];
  13.228 -				csr14val = setup[1];
  13.229 -				csr15dir = (setup[3]<<16) | setup[2];
  13.230 -				csr15val = (setup[4]<<16) | setup[2];
  13.231 -				outl(0, ioaddr + CSR13);
  13.232 -				outl(csr14val, ioaddr + CSR14);
  13.233 -				outl(csr15dir, ioaddr + CSR15);	/* Direction */
  13.234 -				outl(csr15val, ioaddr + CSR15);	/* Data */
  13.235 -				outl(csr13val, ioaddr + CSR13);
  13.236 -			} else {
  13.237 -				csr13val = 1;
  13.238 -				csr14val = 0;
  13.239 -				csr15dir = (setup[0]<<16) | 0x0008;
  13.240 -				csr15val = (setup[1]<<16) | 0x0008;
  13.241 -				if (dev->if_port <= 4)
  13.242 -					csr14val = t21142_csr14[dev->if_port];
  13.243 -				if (startup) {
  13.244 -					outl(0, ioaddr + CSR13);
  13.245 -					outl(csr14val, ioaddr + CSR14);
  13.246 -				}
  13.247 -				outl(csr15dir, ioaddr + CSR15);	/* Direction */
  13.248 -				outl(csr15val, ioaddr + CSR15);	/* Data */
  13.249 -				if (startup) outl(csr13val, ioaddr + CSR13);
  13.250 -			}
  13.251 -			if (tulip_debug > 1)
  13.252 -				printk(KERN_DEBUG "%s:  Setting CSR15 to %8.8x/%8.8x.\n",
  13.253 -					   dev->name, csr15dir, csr15val);
  13.254 -			if (mleaf->type == 4)
  13.255 -				new_csr6 = 0x82020000 | ((setup[2] & 0x71) << 18);
  13.256 -			else
  13.257 -				new_csr6 = 0x82420000;
  13.258 -			break;
  13.259 -		}
  13.260 -		case 1: case 3: {
  13.261 -			int phy_num = p[0];
  13.262 -			int init_length = p[1];
  13.263 -			u16 *misc_info, tmp_info;
  13.264 -
  13.265 -			dev->if_port = 11;
  13.266 -			new_csr6 = 0x020E0000;
  13.267 -			if (mleaf->type == 3) {	/* 21142 */
  13.268 -				u16 *init_sequence = (u16*)(p+2);
  13.269 -				u16 *reset_sequence = &((u16*)(p+3))[init_length];
  13.270 -				int reset_length = p[2 + init_length*2];
  13.271 -				misc_info = reset_sequence + reset_length;
  13.272 -				if (startup)
  13.273 -					for (i = 0; i < reset_length; i++)
  13.274 -						outl(get_u16(&reset_sequence[i]) << 16, ioaddr + CSR15);
  13.275 -				for (i = 0; i < init_length; i++)
  13.276 -					outl(get_u16(&init_sequence[i]) << 16, ioaddr + CSR15);
  13.277 -			} else {
  13.278 -				u8 *init_sequence = p + 2;
  13.279 -				u8 *reset_sequence = p + 3 + init_length;
  13.280 -				int reset_length = p[2 + init_length];
  13.281 -				misc_info = (u16*)(reset_sequence + reset_length);
  13.282 -				if (startup) {
  13.283 -					outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
  13.284 -					for (i = 0; i < reset_length; i++)
  13.285 -						outl(reset_sequence[i], ioaddr + CSR12);
  13.286 -				}
  13.287 -				for (i = 0; i < init_length; i++)
  13.288 -					outl(init_sequence[i], ioaddr + CSR12);
  13.289 -			}
  13.290 -			tmp_info = get_u16(&misc_info[1]);
  13.291 -			if (tmp_info)
  13.292 -				tp->advertising[phy_num] = tmp_info | 1;
  13.293 -			if (tmp_info && startup < 2) {
  13.294 -				if (tp->mii_advertise == 0)
  13.295 -					tp->mii_advertise = tp->advertising[phy_num];
  13.296 -				if (tulip_debug > 1)
  13.297 -					printk(KERN_DEBUG "%s:  Advertising %4.4x on MII %d.\n",
  13.298 -					       dev->name, tp->mii_advertise, tp->phys[phy_num]);
  13.299 -				tulip_mdio_write(dev, tp->phys[phy_num], 4, tp->mii_advertise);
  13.300 -			}
  13.301 -			break;
  13.302 -		}
  13.303 -		case 5: case 6: {
  13.304 -			u16 setup[5];
  13.305 -
  13.306 -			new_csr6 = 0; /* FIXME */
  13.307 -
  13.308 -			for (i = 0; i < 5; i++)
  13.309 -				setup[i] = get_u16(&p[i*2 + 1]);
  13.310 -
  13.311 -			if (startup && mtable->has_reset) {
  13.312 -				struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
  13.313 -				unsigned char *rst = rleaf->leafdata;
  13.314 -				if (tulip_debug > 1)
  13.315 -					printk(KERN_DEBUG "%s: Resetting the transceiver.\n",
  13.316 -						   dev->name);
  13.317 -				for (i = 0; i < rst[0]; i++)
  13.318 -					outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
  13.319 -			}
  13.320 -
  13.321 -			break;
  13.322 -		}
  13.323 -		default:
  13.324 -			printk(KERN_DEBUG "%s:  Invalid media table selection %d.\n",
  13.325 -					   dev->name, mleaf->type);
  13.326 -			new_csr6 = 0x020E0000;
  13.327 -		}
  13.328 -		if (tulip_debug > 1)
  13.329 -			printk(KERN_DEBUG "%s: Using media type %s, CSR12 is %2.2x.\n",
  13.330 -				   dev->name, medianame[dev->if_port],
  13.331 -				   inl(ioaddr + CSR12) & 0xff);
  13.332 -	} else if (tp->chip_id == DC21041) {
  13.333 -		int port = dev->if_port <= 4 ? dev->if_port : 0;
  13.334 -		if (tulip_debug > 1)
  13.335 -			printk(KERN_DEBUG "%s: 21041 using media %s, CSR12 is %4.4x.\n",
  13.336 -				   dev->name, medianame[port == 3 ? 12: port],
  13.337 -				   inl(ioaddr + CSR12));
  13.338 -		outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
  13.339 -		outl(t21041_csr14[port], ioaddr + CSR14);
  13.340 -		outl(t21041_csr15[port], ioaddr + CSR15);
  13.341 -		outl(t21041_csr13[port], ioaddr + CSR13);
  13.342 -		new_csr6 = 0x80020000;
  13.343 -	} else if (tp->chip_id == LC82C168) {
  13.344 -		if (startup && ! tp->medialock)
  13.345 -			dev->if_port = tp->mii_cnt ? 11 : 0;
  13.346 -		if (tulip_debug > 1)
  13.347 -			printk(KERN_DEBUG "%s: PNIC PHY status is %3.3x, media %s.\n",
  13.348 -				   dev->name, inl(ioaddr + 0xB8), medianame[dev->if_port]);
  13.349 -		if (tp->mii_cnt) {
  13.350 -			new_csr6 = 0x810C0000;
  13.351 -			outl(0x0001, ioaddr + CSR15);
  13.352 -			outl(0x0201B07A, ioaddr + 0xB8);
  13.353 -		} else if (startup) {
  13.354 -			/* Start with 10mbps to do autonegotiation. */
  13.355 -			outl(0x32, ioaddr + CSR12);
  13.356 -			new_csr6 = 0x00420000;
  13.357 -			outl(0x0001B078, ioaddr + 0xB8);
  13.358 -			outl(0x0201B078, ioaddr + 0xB8);
  13.359 -		} else if (dev->if_port == 3  ||  dev->if_port == 5) {
  13.360 -			outl(0x33, ioaddr + CSR12);
  13.361 -			new_csr6 = 0x01860000;
  13.362 -			/* Trigger autonegotiation. */
  13.363 -			outl(startup ? 0x0201F868 : 0x0001F868, ioaddr + 0xB8);
  13.364 -		} else {
  13.365 -			outl(0x32, ioaddr + CSR12);
  13.366 -			new_csr6 = 0x00420000;
  13.367 -			outl(0x1F078, ioaddr + 0xB8);
  13.368 -		}
  13.369 -	} else if (tp->chip_id == DC21040) {					/* 21040 */
  13.370 -		/* Turn on the xcvr interface. */
  13.371 -		int csr12 = inl(ioaddr + CSR12);
  13.372 -		if (tulip_debug > 1)
  13.373 -			printk(KERN_DEBUG "%s: 21040 media type is %s, CSR12 is %2.2x.\n",
  13.374 -				   dev->name, medianame[dev->if_port], csr12);
  13.375 -		if (tulip_media_cap[dev->if_port] & MediaAlwaysFD)
  13.376 -			tp->full_duplex = 1;
  13.377 -		new_csr6 = 0x20000;
  13.378 -		/* Set the full duplux match frame. */
  13.379 -		outl(FULL_DUPLEX_MAGIC, ioaddr + CSR11);
  13.380 -		outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
  13.381 -		if (t21040_csr13[dev->if_port] & 8) {
  13.382 -			outl(0x0705, ioaddr + CSR14);
  13.383 -			outl(0x0006, ioaddr + CSR15);
  13.384 -		} else {
  13.385 -			outl(0xffff, ioaddr + CSR14);
  13.386 -			outl(0x0000, ioaddr + CSR15);
  13.387 -		}
  13.388 -		outl(0x8f01 | t21040_csr13[dev->if_port], ioaddr + CSR13);
  13.389 -	} else {					/* Unknown chip type with no media table. */
  13.390 -		if (tp->default_port == 0)
  13.391 -			dev->if_port = tp->mii_cnt ? 11 : 3;
  13.392 -		if (tulip_media_cap[dev->if_port] & MediaIsMII) {
  13.393 -			new_csr6 = 0x020E0000;
  13.394 -		} else if (tulip_media_cap[dev->if_port] & MediaIsFx) {
  13.395 -			new_csr6 = 0x028600000;
  13.396 -		} else
  13.397 -			new_csr6 = 0x038600000;
  13.398 -		if (tulip_debug > 1)
  13.399 -			printk(KERN_DEBUG "%s: No media description table, assuming "
  13.400 -				   "%s transceiver, CSR12 %2.2x.\n",
  13.401 -				   dev->name, medianame[dev->if_port],
  13.402 -				   inl(ioaddr + CSR12));
  13.403 -	}
  13.404 -
  13.405 -	tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
  13.406 -	return;
  13.407 -}
  13.408 -
  13.409 -/*
  13.410 -  Check the MII negotiated duplex and change the CSR6 setting if
  13.411 -  required.
  13.412 -  Return 0 if everything is OK.
  13.413 -  Return < 0 if the transceiver is missing or has no link beat.
  13.414 -  */
  13.415 -int tulip_check_duplex(struct net_device *dev)
  13.416 -{
  13.417 -	struct tulip_private *tp = dev->priv;
  13.418 -	unsigned int bmsr, lpa, negotiated, new_csr6;
  13.419 -
  13.420 -	bmsr = tulip_mdio_read(dev, tp->phys[0], MII_BMSR);
  13.421 -	lpa = tulip_mdio_read(dev, tp->phys[0], MII_LPA);
  13.422 -	if (tulip_debug > 1)
  13.423 -		printk(KERN_INFO "%s: MII status %4.4x, Link partner report "
  13.424 -			   "%4.4x.\n", dev->name, bmsr, lpa);
  13.425 -	if (bmsr == 0xffff)
  13.426 -		return -2;
  13.427 -	if ((bmsr & BMSR_LSTATUS) == 0) {
  13.428 -		int new_bmsr = tulip_mdio_read(dev, tp->phys[0], MII_BMSR);
  13.429 -		if ((new_bmsr & BMSR_LSTATUS) == 0) {
  13.430 -			if (tulip_debug  > 1)
  13.431 -				printk(KERN_INFO "%s: No link beat on the MII interface,"
  13.432 -					   " status %4.4x.\n", dev->name, new_bmsr);
  13.433 -			return -1;
  13.434 -		}
  13.435 -	}
  13.436 -	negotiated = lpa & tp->advertising[0];
  13.437 -	tp->full_duplex = mii_duplex(tp->full_duplex_lock, negotiated);
  13.438 -
  13.439 -	new_csr6 = tp->csr6;
  13.440 -
  13.441 -	if (negotiated & LPA_100) new_csr6 &= ~TxThreshold;
  13.442 -	else			  new_csr6 |= TxThreshold;
  13.443 -	if (tp->full_duplex) new_csr6 |= FullDuplex;
  13.444 -	else		     new_csr6 &= ~FullDuplex;
  13.445 -
  13.446 -	if (new_csr6 != tp->csr6) {
  13.447 -		tp->csr6 = new_csr6;
  13.448 -		tulip_restart_rxtx(tp);
  13.449 -
  13.450 -		if (tulip_debug > 0)
  13.451 -			printk(KERN_INFO "%s: Setting %s-duplex based on MII"
  13.452 -				   "#%d link partner capability of %4.4x.\n",
  13.453 -				   dev->name, tp->full_duplex ? "full" : "half",
  13.454 -				   tp->phys[0], lpa);
  13.455 -		return 1;
  13.456 -	}
  13.457 -
  13.458 -	return 0;
  13.459 -}
  13.460 -
  13.461 -void __devinit tulip_find_mii (struct net_device *dev, int board_idx)
  13.462 -{
  13.463 -	struct tulip_private *tp = dev->priv;
  13.464 -	int phyn, phy_idx = 0;
  13.465 -	int mii_reg0;
  13.466 -	int mii_advert;
  13.467 -	unsigned int to_advert, new_bmcr, ane_switch;
  13.468 -
  13.469 -	/* Find the connected MII xcvrs.
  13.470 -	   Doing this in open() would allow detecting external xcvrs later,
  13.471 -	   but takes much time. */
  13.472 -	for (phyn = 1; phyn <= 32 && phy_idx < sizeof (tp->phys); phyn++) {
  13.473 -		int phy = phyn & 0x1f;
  13.474 -		int mii_status = tulip_mdio_read (dev, phy, MII_BMSR);
  13.475 -		if ((mii_status & 0x8301) == 0x8001 ||
  13.476 -		    ((mii_status & BMSR_100BASE4) == 0
  13.477 -		     && (mii_status & 0x7800) != 0)) {
  13.478 -			/* preserve Becker logic, gain indentation level */
  13.479 -		} else {
  13.480 -			continue;
  13.481 -		}
  13.482 -
  13.483 -		mii_reg0 = tulip_mdio_read (dev, phy, MII_BMCR);
  13.484 -		mii_advert = tulip_mdio_read (dev, phy, MII_ADVERTISE);
  13.485 -		ane_switch = 0;
  13.486 -
  13.487 -		/* if not advertising at all, gen an
  13.488 -		 * advertising value from the capability
  13.489 -		 * bits in BMSR
  13.490 -		 */
  13.491 -		if ((mii_advert & ADVERTISE_ALL) == 0) {
  13.492 -			unsigned int tmpadv = tulip_mdio_read (dev, phy, MII_BMSR);
  13.493 -			mii_advert = ((tmpadv >> 6) & 0x3e0) | 1;
  13.494 -		}
  13.495 -
  13.496 -		if (tp->mii_advertise) {
  13.497 -			tp->advertising[phy_idx] =
  13.498 -			to_advert = tp->mii_advertise;
  13.499 -		} else if (tp->advertising[phy_idx]) {
  13.500 -			to_advert = tp->advertising[phy_idx];
  13.501 -		} else {
  13.502 -			tp->advertising[phy_idx] =
  13.503 -			tp->mii_advertise =
  13.504 -			to_advert = mii_advert;
  13.505 -		}
  13.506 -
  13.507 -		tp->phys[phy_idx++] = phy;
  13.508 -
  13.509 -		printk (KERN_INFO "tulip%d:  MII transceiver #%d "
  13.510 -			"config %4.4x status %4.4x advertising %4.4x.\n",
  13.511 -			board_idx, phy, mii_reg0, mii_status, mii_advert);
  13.512 -
  13.513 -		/* Fixup for DLink with miswired PHY. */
  13.514 -		if (mii_advert != to_advert) {
  13.515 -			printk (KERN_DEBUG "tulip%d:  Advertising %4.4x on PHY %d,"
  13.516 -				" previously advertising %4.4x.\n",
  13.517 -				board_idx, to_advert, phy, mii_advert);
  13.518 -			tulip_mdio_write (dev, phy, 4, to_advert);
  13.519 -		}
  13.520 -
  13.521 -		/* Enable autonegotiation: some boards default to off. */
  13.522 -		if (tp->default_port == 0) {
  13.523 -			new_bmcr = mii_reg0 | BMCR_ANENABLE;
  13.524 -			if (new_bmcr != mii_reg0) {
  13.525 -				new_bmcr |= BMCR_ANRESTART;
  13.526 -				ane_switch = 1;
  13.527 -			}
  13.528 -		}
  13.529 -		/* ...or disable nway, if forcing media */
  13.530 -		else {
  13.531 -			new_bmcr = mii_reg0 & ~BMCR_ANENABLE;
  13.532 -			if (new_bmcr != mii_reg0)
  13.533 -				ane_switch = 1;
  13.534 -		}
  13.535 -
  13.536 -		/* clear out bits we never want at this point */
  13.537 -		new_bmcr &= ~(BMCR_CTST | BMCR_FULLDPLX | BMCR_ISOLATE |
  13.538 -			      BMCR_PDOWN | BMCR_SPEED100 | BMCR_LOOPBACK |
  13.539 -			      BMCR_RESET);
  13.540 -
  13.541 -		if (tp->full_duplex)
  13.542 -			new_bmcr |= BMCR_FULLDPLX;
  13.543 -		if (tulip_media_cap[tp->default_port] & MediaIs100)
  13.544 -			new_bmcr |= BMCR_SPEED100;
  13.545 -
  13.546 -		if (new_bmcr != mii_reg0) {
  13.547 -			/* some phys need the ANE switch to
  13.548 -			 * happen before forced media settings
  13.549 -			 * will "take."  However, we write the
  13.550 -			 * same value twice in order not to
  13.551 -			 * confuse the sane phys.
  13.552 -			 */
  13.553 -			if (ane_switch) {
  13.554 -				tulip_mdio_write (dev, phy, MII_BMCR, new_bmcr);
  13.555 -				udelay (10);
  13.556 -			}
  13.557 -			tulip_mdio_write (dev, phy, MII_BMCR, new_bmcr);
  13.558 -		}
  13.559 -	}
  13.560 -	tp->mii_cnt = phy_idx;
  13.561 -	if (tp->mtable && tp->mtable->has_mii && phy_idx == 0) {
  13.562 -		printk (KERN_INFO "tulip%d: ***WARNING***: No MII transceiver found!\n",
  13.563 -			board_idx);
  13.564 -		tp->phys[0] = 1;
  13.565 -	}
  13.566 -}
    14.1 --- a/xen-2.4.16/drivers/net/tulip/pnic.c	Fri Feb 14 17:11:31 2003 +0000
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,171 +0,0 @@
    14.4 -/*
    14.5 -	drivers/net/tulip/pnic.c
    14.6 -
    14.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
    14.8 -	Copyright 2000,2001  The Linux Kernel Team
    14.9 -	Written/copyright 1994-2001 by Donald Becker.
   14.10 -
   14.11 -	This software may be used and distributed according to the terms
   14.12 -	of the GNU General Public License, incorporated herein by reference.
   14.13 -
   14.14 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   14.15 -	for more information on this driver, or visit the project
   14.16 -	Web page at http://sourceforge.net/projects/tulip/
   14.17 -
   14.18 -*/
   14.19 -
   14.20 -//#include <linux/kernel.h>
   14.21 -#include "tulip.h"
   14.22 -
   14.23 -
   14.24 -void pnic_do_nway(struct net_device *dev)
   14.25 -{
   14.26 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   14.27 -	long ioaddr = dev->base_addr;
   14.28 -	u32 phy_reg = inl(ioaddr + 0xB8);
   14.29 -	u32 new_csr6 = tp->csr6 & ~0x40C40200;
   14.30 -
   14.31 -	if (phy_reg & 0x78000000) { /* Ignore baseT4 */
   14.32 -		if (phy_reg & 0x20000000)		dev->if_port = 5;
   14.33 -		else if (phy_reg & 0x40000000)	dev->if_port = 3;
   14.34 -		else if (phy_reg & 0x10000000)	dev->if_port = 4;
   14.35 -		else if (phy_reg & 0x08000000)	dev->if_port = 0;
   14.36 -		tp->nwayset = 1;
   14.37 -		new_csr6 = (dev->if_port & 1) ? 0x01860000 : 0x00420000;
   14.38 -		outl(0x32 | (dev->if_port & 1), ioaddr + CSR12);
   14.39 -		if (dev->if_port & 1)
   14.40 -			outl(0x1F868, ioaddr + 0xB8);
   14.41 -		if (phy_reg & 0x30000000) {
   14.42 -			tp->full_duplex = 1;
   14.43 -			new_csr6 |= 0x00000200;
   14.44 -		}
   14.45 -		if (tulip_debug > 1)
   14.46 -			printk(KERN_DEBUG "%s: PNIC autonegotiated status %8.8x, %s.\n",
   14.47 -				   dev->name, phy_reg, medianame[dev->if_port]);
   14.48 -		if (tp->csr6 != new_csr6) {
   14.49 -			tp->csr6 = new_csr6;
   14.50 -			/* Restart Tx */
   14.51 -			tulip_restart_rxtx(tp);
   14.52 -			dev->trans_start = jiffies;
   14.53 -		}
   14.54 -	}
   14.55 -}
   14.56 -
   14.57 -void pnic_lnk_change(struct net_device *dev, int csr5)
   14.58 -{
   14.59 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   14.60 -	long ioaddr = dev->base_addr;
   14.61 -	int phy_reg = inl(ioaddr + 0xB8);
   14.62 -
   14.63 -	if (tulip_debug > 1)
   14.64 -		printk(KERN_DEBUG "%s: PNIC link changed state %8.8x, CSR5 %8.8x.\n",
   14.65 -			   dev->name, phy_reg, csr5);
   14.66 -	if (inl(ioaddr + CSR5) & TPLnkFail) {
   14.67 -		outl((inl(ioaddr + CSR7) & ~TPLnkFail) | TPLnkPass, ioaddr + CSR7);
   14.68 -		/* If we use an external MII, then we mustn't use the
   14.69 -		 * internal negotiation.
   14.70 -		 */
   14.71 -		if (tulip_media_cap[dev->if_port] & MediaIsMII)
   14.72 -			return;
   14.73 -		if (! tp->nwayset  ||  jiffies - dev->trans_start > 1*HZ) {
   14.74 -			tp->csr6 = 0x00420000 | (tp->csr6 & 0x0000fdff);
   14.75 -			outl(tp->csr6, ioaddr + CSR6);
   14.76 -			outl(0x30, ioaddr + CSR12);
   14.77 -			outl(0x0201F078, ioaddr + 0xB8); /* Turn on autonegotiation. */
   14.78 -			dev->trans_start = jiffies;
   14.79 -		}
   14.80 -	} else if (inl(ioaddr + CSR5) & TPLnkPass) {
   14.81 -		if (tulip_media_cap[dev->if_port] & MediaIsMII) {
   14.82 -			spin_lock(&tp->lock);
   14.83 -			tulip_check_duplex(dev);
   14.84 -			spin_unlock(&tp->lock);
   14.85 -		} else {
   14.86 -			pnic_do_nway(dev);
   14.87 -		}
   14.88 -		outl((inl(ioaddr + CSR7) & ~TPLnkPass) | TPLnkFail, ioaddr + CSR7);
   14.89 -	}
   14.90 -}
   14.91 -
   14.92 -void pnic_timer(unsigned long data)
   14.93 -{
   14.94 -	struct net_device *dev = (struct net_device *)data;
   14.95 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   14.96 -	long ioaddr = dev->base_addr;
   14.97 -	int next_tick = 60*HZ;
   14.98 -
   14.99 -	if(!inl(ioaddr + CSR7)) {
  14.100 -		/* the timer was called due to a work overflow
  14.101 -		 * in the interrupt handler. Skip the connection
  14.102 -		 * checks, the nic is definitively speaking with
  14.103 -		 * his link partner.
  14.104 -		 */
  14.105 -		goto too_good_connection;
  14.106 -	}
  14.107 -
  14.108 -	if (tulip_media_cap[dev->if_port] & MediaIsMII) {
  14.109 -		spin_lock_irq(&tp->lock);
  14.110 -		if (tulip_check_duplex(dev) > 0)
  14.111 -			next_tick = 3*HZ;
  14.112 -		spin_unlock_irq(&tp->lock);
  14.113 -	} else {
  14.114 -		int csr12 = inl(ioaddr + CSR12);
  14.115 -		int new_csr6 = tp->csr6 & ~0x40C40200;
  14.116 -		int phy_reg = inl(ioaddr + 0xB8);
  14.117 -		int csr5 = inl(ioaddr + CSR5);
  14.118 -
  14.119 -		if (tulip_debug > 1)
  14.120 -			printk(KERN_DEBUG "%s: PNIC timer PHY status %8.8x, %s "
  14.121 -				   "CSR5 %8.8x.\n",
  14.122 -				   dev->name, phy_reg, medianame[dev->if_port], csr5);
  14.123 -		if (phy_reg & 0x04000000) {	/* Remote link fault */
  14.124 -			outl(0x0201F078, ioaddr + 0xB8);
  14.125 -			next_tick = 1*HZ;
  14.126 -			tp->nwayset = 0;
  14.127 -		} else if (phy_reg & 0x78000000) { /* Ignore baseT4 */
  14.128 -			pnic_do_nway(dev);
  14.129 -			next_tick = 60*HZ;
  14.130 -		} else if (csr5 & TPLnkFail) { /* 100baseTx link beat */
  14.131 -			if (tulip_debug > 1)
  14.132 -				printk(KERN_DEBUG "%s: %s link beat failed, CSR12 %4.4x, "
  14.133 -					   "CSR5 %8.8x, PHY %3.3x.\n",
  14.134 -					   dev->name, medianame[dev->if_port], csr12,
  14.135 -					   inl(ioaddr + CSR5), inl(ioaddr + 0xB8));
  14.136 -			next_tick = 3*HZ;
  14.137 -			if (tp->medialock) {
  14.138 -			} else if (tp->nwayset  &&  (dev->if_port & 1)) {
  14.139 -				next_tick = 1*HZ;
  14.140 -			} else if (dev->if_port == 0) {
  14.141 -				dev->if_port = 3;
  14.142 -				outl(0x33, ioaddr + CSR12);
  14.143 -				new_csr6 = 0x01860000;
  14.144 -				outl(0x1F868, ioaddr + 0xB8);
  14.145 -			} else {
  14.146 -				dev->if_port = 0;
  14.147 -				outl(0x32, ioaddr + CSR12);
  14.148 -				new_csr6 = 0x00420000;
  14.149 -				outl(0x1F078, ioaddr + 0xB8);
  14.150 -			}
  14.151 -			if (tp->csr6 != new_csr6) {
  14.152 -				tp->csr6 = new_csr6;
  14.153 -				/* Restart Tx */
  14.154 -				tulip_restart_rxtx(tp);
  14.155 -				dev->trans_start = jiffies;
  14.156 -				if (tulip_debug > 1)
  14.157 -					printk(KERN_INFO "%s: Changing PNIC configuration to %s "
  14.158 -						   "%s-duplex, CSR6 %8.8x.\n",
  14.159 -						   dev->name, medianame[dev->if_port],
  14.160 -						   tp->full_duplex ? "full" : "half", new_csr6);
  14.161 -			}
  14.162 -		}
  14.163 -	}
  14.164 -too_good_connection:
  14.165 -	mod_timer(&tp->timer, RUN_AT(next_tick));
  14.166 -	if(!inl(ioaddr + CSR7)) {
  14.167 -		if (tulip_debug > 1)
  14.168 -			printk(KERN_INFO "%s: sw timer wakeup.\n", dev->name);
  14.169 -		disable_irq(dev->irq);
  14.170 -		tulip_refill_rx(dev);
  14.171 -		enable_irq(dev->irq);
  14.172 -		outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
  14.173 -	}
  14.174 -}
    15.1 --- a/xen-2.4.16/drivers/net/tulip/pnic2.c	Fri Feb 14 17:11:31 2003 +0000
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,407 +0,0 @@
    15.4 -/*
    15.5 -	drivers/net/tulip/pnic2.c
    15.6 -
    15.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
    15.8 -	Copyright 2000,2001  The Linux Kernel Team
    15.9 -	Written/copyright 1994-2001 by Donald Becker.
   15.10 -        Modified to hep support PNIC_II by Kevin B. Hendricks
   15.11 -
   15.12 -	This software may be used and distributed according to the terms
   15.13 -	of the GNU General Public License, incorporated herein by reference.
   15.14 -
   15.15 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   15.16 -	for more information on this driver, or visit the project
   15.17 -	Web page at http://sourceforge.net/projects/tulip/
   15.18 -
   15.19 -*/
   15.20 -
   15.21 -
   15.22 -/* Understanding the PNIC_II - everything is this file is based
   15.23 - * on the PNIC_II_PDF datasheet which is sorely lacking in detail
   15.24 - *
   15.25 - * As I understand things, here are the registers and bits that
   15.26 - * explain the masks and constants used in this file that are
   15.27 - * either different from the 21142/3 or important for basic operation.
   15.28 - *
   15.29 - *
   15.30 - * CSR 6  (mask = 0xfe3bd1fd of bits not to change)
   15.31 - * -----
   15.32 - * Bit 24    - SCR
   15.33 - * Bit 23    - PCS
   15.34 - * Bit 22    - TTM (Trasmit Threshold Mode)
   15.35 - * Bit 18    - Port Select
   15.36 - * Bit 13    - Start - 1, Stop - 0 Transmissions
   15.37 - * Bit 11:10 - Loop Back Operation Mode
   15.38 - * Bit 9     - Full Duplex mode (Advertise 10BaseT-FD is CSR14<7> is set)
   15.39 - * Bit 1     - Start - 1, Stop - 0 Receive
   15.40 - *
   15.41 - *
   15.42 - * CSR 14  (mask = 0xfff0ee39 of bits not to change)
   15.43 - * ------
   15.44 - * Bit 19    - PAUSE-Pause
   15.45 - * Bit 18    - Advertise T4
   15.46 - * Bit 17    - Advertise 100baseTx-FD
   15.47 - * Bit 16    - Advertise 100baseTx-HD
   15.48 - * Bit 12    - LTE - Link Test Enable
   15.49 - * Bit 7     - ANE - Auto Negotiate Enable
   15.50 - * Bit 6     - HDE - Advertise 10baseT-HD
   15.51 - * Bit 2     - Reset to Power down - kept as 1 for normal operation
   15.52 - * Bit 1     -  Loop Back enable for 10baseT MCC
   15.53 - *
   15.54 - *
   15.55 - * CSR 12
   15.56 - * ------
   15.57 - * Bit 25    - Partner can do T4
   15.58 - * Bit 24    - Partner can do 100baseTx-FD
   15.59 - * Bit 23    - Partner can do 100baseTx-HD
   15.60 - * Bit 22    - Partner can do 10baseT-FD
   15.61 - * Bit 21    - Partner can do 10baseT-HD
   15.62 - * Bit 15    - LPN is 1 if all above bits are valid other wise 0
   15.63 - * Bit 14:12 - autonegotiation state (write 001 to start autonegotiate)
   15.64 - * Bit 3     - Autopolarity state
   15.65 - * Bit 2     - LS10B - link state of 10baseT 0 - good, 1 - failed
   15.66 - * Bit 1     - LS100B - link state of 100baseT 0 - good, 1- faild
   15.67 - *
   15.68 - *
   15.69 - * Data Port Selection Info
   15.70 - *-------------------------
   15.71 - *
   15.72 - * CSR14<7>   CSR6<18>    CSR6<22>    CSR6<23>    CSR6<24>   MODE/PORT
   15.73 - *   1           0           0 (X)       0 (X)       1        NWAY
   15.74 - *   0           0           1           0 (X)       0        10baseT
   15.75 - *   0           1           0           1           1 (X)    100baseT
   15.76 - *
   15.77 - *
   15.78 - */
   15.79 -
   15.80 -
   15.81 -
   15.82 -#include "tulip.h"
   15.83 -#include <linux/pci.h>
   15.84 -#include <linux/delay.h>
   15.85 -
   15.86 -
   15.87 -void pnic2_timer(unsigned long data)
   15.88 -{
   15.89 -	struct net_device *dev = (struct net_device *)data;
   15.90 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   15.91 -	long ioaddr = dev->base_addr;
   15.92 -	int next_tick = 60*HZ;
   15.93 -
   15.94 -	if (tulip_debug > 3)
   15.95 -		printk(KERN_INFO"%s: PNIC2 negotiation status %8.8x.\n",
   15.96 -                    dev->name,inl(ioaddr + CSR12));
   15.97 -
   15.98 -	if (next_tick) {
   15.99 -		mod_timer(&tp->timer, RUN_AT(next_tick));
  15.100 -	}
  15.101 -}
  15.102 -
  15.103 -
  15.104 -void pnic2_start_nway(struct net_device *dev)
  15.105 -{
  15.106 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  15.107 -	long ioaddr = dev->base_addr;
  15.108 -        int csr14;
  15.109 -        int csr12;
  15.110 -
  15.111 -        /* set up what to advertise during the negotiation */
  15.112 -
  15.113 -        /* load in csr14  and mask off bits not to touch
  15.114 -         * comment at top of file explains mask value
  15.115 -         */
  15.116 -	csr14 = (inl(ioaddr + CSR14) & 0xfff0ee39);
  15.117 -
  15.118 -        /* bit 17 - advetise 100baseTx-FD */
  15.119 -        if (tp->sym_advertise & 0x0100) csr14 |= 0x00020000;
  15.120 -
  15.121 -        /* bit 16 - advertise 100baseTx-HD */
  15.122 -        if (tp->sym_advertise & 0x0080) csr14 |= 0x00010000;
  15.123 -
  15.124 -        /* bit 6 - advertise 10baseT-HD */
  15.125 -        if (tp->sym_advertise & 0x0020) csr14 |= 0x00000040;
  15.126 -
  15.127 -        /* Now set bit 12 Link Test Enable, Bit 7 Autonegotiation Enable
  15.128 -         * and bit 0 Don't PowerDown 10baseT
  15.129 -         */
  15.130 -        csr14 |= 0x00001184;
  15.131 -
  15.132 -	if (tulip_debug > 1)
  15.133 -		printk(KERN_DEBUG "%s: Restarting PNIC2 autonegotiation, "
  15.134 -                      "csr14=%8.8x.\n", dev->name, csr14);
  15.135 -
  15.136 -        /* tell pnic2_lnk_change we are doing an nway negotiation */
  15.137 -	dev->if_port = 0;
  15.138 -	tp->nway = tp->mediasense = 1;
  15.139 -	tp->nwayset = tp->lpar = 0;
  15.140 -
  15.141 -        /* now we have to set up csr6 for NWAY state */
  15.142 -
  15.143 -	tp->csr6 = inl(ioaddr + CSR6);
  15.144 -	if (tulip_debug > 1)
  15.145 -		printk(KERN_DEBUG "%s: On Entry to Nway, "
  15.146 -                      "csr6=%8.8x.\n", dev->name, tp->csr6);
  15.147 -
  15.148 -        /* mask off any bits not to touch
  15.149 -         * comment at top of file explains mask value
  15.150 -         */
  15.151 -	tp->csr6 = tp->csr6 & 0xfe3bd1fd;
  15.152 -
  15.153 -        /* don't forget that bit 9 is also used for advertising */
  15.154 -        /* advertise 10baseT-FD for the negotiation (bit 9) */
  15.155 -        if (tp->sym_advertise & 0x0040) tp->csr6 |= 0x00000200;
  15.156 -
  15.157 -        /* set bit 24 for nway negotiation mode ...
  15.158 -         * see Data Port Selection comment at top of file
  15.159 -         * and "Stop" - reset both Transmit (bit 13) and Receive (bit 1)
  15.160 -         */
  15.161 -        tp->csr6 |= 0x01000000;
  15.162 -	outl(csr14, ioaddr + CSR14);
  15.163 -	outl(tp->csr6, ioaddr + CSR6);
  15.164 -        udelay(100);
  15.165 -
  15.166 -        /* all set up so now force the negotiation to begin */
  15.167 -
  15.168 -        /* read in current values and mask off all but the
  15.169 -	 * Autonegotiation bits 14:12.  Writing a 001 to those bits
  15.170 -         * should start the autonegotiation
  15.171 -         */
  15.172 -        csr12 = (inl(ioaddr + CSR12) & 0xffff8fff);
  15.173 -        csr12 |= 0x1000;
  15.174 -	outl(csr12, ioaddr + CSR12);
  15.175 -}
  15.176 -
  15.177 -
  15.178 -
  15.179 -void pnic2_lnk_change(struct net_device *dev, int csr5)
  15.180 -{
  15.181 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  15.182 -	long ioaddr = dev->base_addr;
  15.183 -        int csr14;
  15.184 -
  15.185 -        /* read the staus register to find out what is up */
  15.186 -	int csr12 = inl(ioaddr + CSR12);
  15.187 -
  15.188 -	if (tulip_debug > 1)
  15.189 -		printk(KERN_INFO"%s: PNIC2 link status interrupt %8.8x, "
  15.190 -                       " CSR5 %x, %8.8x.\n", dev->name, csr12,
  15.191 -                       csr5, inl(ioaddr + CSR14));
  15.192 -
  15.193 -	/* If NWay finished and we have a negotiated partner capability.
  15.194 -         * check bits 14:12 for bit pattern 101 - all is good
  15.195 -         */
  15.196 -	if (tp->nway  &&  !tp->nwayset) {
  15.197 -
  15.198 -	        /* we did an auto negotiation */
  15.199 -
  15.200 -                if ((csr12 & 0x7000) == 0x5000) {
  15.201 -
  15.202 -	               /* negotiation ended successfully */
  15.203 -
  15.204 -	               /* get the link partners reply and mask out all but
  15.205 -                        * bits 24-21 which show the partners capabilites
  15.206 -                        * and match those to what we advertised
  15.207 -                        *
  15.208 -                        * then begin to interpret the results of the negotiation.
  15.209 -                        * Always go in this order : (we are ignoring T4 for now)
  15.210 -                        *     100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD
  15.211 -                        */
  15.212 -
  15.213 -		        int negotiated = ((csr12 >> 16) & 0x01E0) & tp->sym_advertise;
  15.214 -		        tp->lpar = (csr12 >> 16);
  15.215 -		        tp->nwayset = 1;
  15.216 -
  15.217 -                        if (negotiated & 0x0100)        dev->if_port = 5;
  15.218 -		        else if (negotiated & 0x0080)	dev->if_port = 3;
  15.219 -		        else if (negotiated & 0x0040)	dev->if_port = 4;
  15.220 -			else if (negotiated & 0x0020)	dev->if_port = 0;
  15.221 -			else {
  15.222 -			     if (tulip_debug > 1)
  15.223 -		                   printk(KERN_INFO "%s: funny autonegotiate result "
  15.224 -                                        "csr12 %8.8x advertising %4.4x\n",
  15.225 -			                 dev->name, csr12, tp->sym_advertise);
  15.226 -			     tp->nwayset = 0;
  15.227 -			     /* so check  if 100baseTx link state is okay */
  15.228 -			     if ((csr12 & 2) == 0  &&  (tp->sym_advertise & 0x0180))
  15.229 -			       dev->if_port = 3;
  15.230 -			}
  15.231 -
  15.232 -			/* now record the duplex that was negotiated */
  15.233 -			tp->full_duplex = 0;
  15.234 -			if ((dev->if_port == 4) || (dev->if_port == 5))
  15.235 -			       tp->full_duplex = 1;
  15.236 -
  15.237 -			if (tulip_debug > 1) {
  15.238 -			       if (tp->nwayset)
  15.239 -			             printk(KERN_INFO "%s: Switching to %s based on link "
  15.240 -				    "negotiation %4.4x & %4.4x = %4.4x.\n",
  15.241 -				     dev->name, medianame[dev->if_port],
  15.242 -                                     tp->sym_advertise, tp->lpar, negotiated);
  15.243 -			}
  15.244 -
  15.245 -                        /* remember to turn off bit 7 - autonegotiate
  15.246 -                         * enable so we can properly end nway mode and
  15.247 -                         * set duplex (ie. use csr6<9> again)
  15.248 -                         */
  15.249 -	                csr14 = (inl(ioaddr + CSR14) & 0xffffff7f);
  15.250 -                        outl(csr14,ioaddr + CSR14);
  15.251 -
  15.252 -
  15.253 -                        /* now set the data port and operating mode
  15.254 -			 * (see the Data Port Selection comments at
  15.255 -			 * the top of the file
  15.256 -			 */
  15.257 -
  15.258 -			/* get current csr6 and mask off bits not to touch */
  15.259 -			/* see comment at top of file */
  15.260 -
  15.261 -			tp->csr6 = (inl(ioaddr + CSR6) & 0xfe3bd1fd);
  15.262 -
  15.263 -			/* so if using if_port 3 or 5 then select the 100baseT
  15.264 -			 * port else select the 10baseT port.
  15.265 -			 * See the Data Port Selection table at the top
  15.266 -			 * of the file which was taken from the PNIC_II.PDF
  15.267 -			 * datasheet
  15.268 -			 */
  15.269 -			if (dev->if_port & 1) tp->csr6 |= 0x01840000;
  15.270 -			else tp->csr6 |= 0x00400000;
  15.271 -
  15.272 -			/* now set the full duplex bit appropriately */
  15.273 -			if (tp->full_duplex) tp->csr6 |= 0x00000200;
  15.274 -
  15.275 -			outl(1, ioaddr + CSR13);
  15.276 -
  15.277 -			if (tulip_debug > 2)
  15.278 -			        printk(KERN_DEBUG "%s:  Setting CSR6 %8.8x/%x CSR12 "
  15.279 -                                      "%8.8x.\n", dev->name, tp->csr6,
  15.280 -                                      inl(ioaddr + CSR6), inl(ioaddr + CSR12));
  15.281 -
  15.282 -			/* now the following actually writes out the
  15.283 -			 * new csr6 values
  15.284 -			 */
  15.285 -			tulip_start_rxtx(tp);
  15.286 -
  15.287 -                        return;
  15.288 -
  15.289 -	        } else {
  15.290 -	                printk(KERN_INFO "%s: Autonegotiation failed, "
  15.291 -                                    "using %s, link beat status %4.4x.\n",
  15.292 -				     dev->name, medianame[dev->if_port], csr12);
  15.293 -
  15.294 -                        /* remember to turn off bit 7 - autonegotiate
  15.295 -                         * enable so we don't forget
  15.296 -                         */
  15.297 -	                csr14 = (inl(ioaddr + CSR14) & 0xffffff7f);
  15.298 -                        outl(csr14,ioaddr + CSR14);
  15.299 -
  15.300 -                        /* what should we do when autonegotiate fails?
  15.301 -                         * should we try again or default to baseline
  15.302 -                         * case.  I just don't know.
  15.303 -                         *
  15.304 -                         * for now default to some baseline case
  15.305 -                         */
  15.306 -
  15.307 -	                 dev->if_port = 0;
  15.308 -                         tp->nway = 0;
  15.309 -                         tp->nwayset = 1;
  15.310 -
  15.311 -                         /* set to 10baseTx-HD - see Data Port Selection
  15.312 -                          * comment given at the top of the file
  15.313 -                          */
  15.314 -	                 tp->csr6 = (inl(ioaddr + CSR6) & 0xfe3bd1fd);
  15.315 -                         tp->csr6 |= 0x00400000;
  15.316 -
  15.317 -	                 tulip_restart_rxtx(tp);
  15.318 -
  15.319 -                         return;
  15.320 -
  15.321 -		}
  15.322 -	}
  15.323 -
  15.324 -	if ((tp->nwayset  &&  (csr5 & 0x08000000)
  15.325 -			  && (dev->if_port == 3  ||  dev->if_port == 5)
  15.326 -			  && (csr12 & 2) == 2) || (tp->nway && (csr5 & (TPLnkFail)))) {
  15.327 -
  15.328 -		/* Link blew? Maybe restart NWay. */
  15.329 -
  15.330 -		if (tulip_debug > 2)
  15.331 -			printk(KERN_DEBUG "%s: Ugh! Link blew?\n", dev->name);
  15.332 -
  15.333 -		del_timer_sync(&tp->timer);
  15.334 -		pnic2_start_nway(dev);
  15.335 -		tp->timer.expires = RUN_AT(3*HZ);
  15.336 -		add_timer(&tp->timer);
  15.337 -
  15.338 -                return;
  15.339 -	}
  15.340 -
  15.341 -
  15.342 -        if (dev->if_port == 3  ||  dev->if_port == 5) {
  15.343 -
  15.344 -	        /* we are at 100mb and a potential link change occurred */
  15.345 -
  15.346 -		if (tulip_debug > 1)
  15.347 -			printk(KERN_INFO"%s: PNIC2 %s link beat %s.\n",
  15.348 -				   dev->name, medianame[dev->if_port],
  15.349 -				   (csr12 & 2) ? "failed" : "good");
  15.350 -
  15.351 -                /* check 100 link beat */
  15.352 -
  15.353 -                tp->nway = 0;
  15.354 -                tp->nwayset = 1;
  15.355 -
  15.356 -                /* if failed then try doing an nway to get in sync */
  15.357 -		if ((csr12 & 2)  &&  ! tp->medialock) {
  15.358 -			del_timer_sync(&tp->timer);
  15.359 -			pnic2_start_nway(dev);
  15.360 -			tp->timer.expires = RUN_AT(3*HZ);
  15.361 -       			add_timer(&tp->timer);
  15.362 -                }
  15.363 -
  15.364 -                return;
  15.365 -        }
  15.366 -
  15.367 -	if (dev->if_port == 0  ||  dev->if_port == 4) {
  15.368 -
  15.369 -	        /* we are at 10mb and a potential link change occurred */
  15.370 -
  15.371 -		if (tulip_debug > 1)
  15.372 -			printk(KERN_INFO"%s: PNIC2 %s link beat %s.\n",
  15.373 -				   dev->name, medianame[dev->if_port],
  15.374 -				   (csr12 & 4) ? "failed" : "good");
  15.375 -
  15.376 -
  15.377 -                tp->nway = 0;
  15.378 -                tp->nwayset = 1;
  15.379 -
  15.380 -                /* if failed, try doing an nway to get in sync */
  15.381 -		if ((csr12 & 4)  &&  ! tp->medialock) {
  15.382 -			del_timer_sync(&tp->timer);
  15.383 -			pnic2_start_nway(dev);
  15.384 -			tp->timer.expires = RUN_AT(3*HZ);
  15.385 -       			add_timer(&tp->timer);
  15.386 -                }
  15.387 -
  15.388 -                return;
  15.389 -        }
  15.390 -
  15.391 -
  15.392 -	if (tulip_debug > 1)
  15.393 -		printk(KERN_INFO"%s: PNIC2 Link Change Default?\n",dev->name);
  15.394 -
  15.395 -        /* if all else fails default to trying 10baseT-HD */
  15.396 -	dev->if_port = 0;
  15.397 -
  15.398 -        /* make sure autonegotiate enable is off */
  15.399 -	csr14 = (inl(ioaddr + CSR14) & 0xffffff7f);
  15.400 -        outl(csr14,ioaddr + CSR14);
  15.401 -
  15.402 -        /* set to 10baseTx-HD - see Data Port Selection
  15.403 -         * comment given at the top of the file
  15.404 -         */
  15.405 -	tp->csr6 = (inl(ioaddr + CSR6) & 0xfe3bd1fd);
  15.406 -        tp->csr6 |= 0x00400000;
  15.407 -
  15.408 -	tulip_restart_rxtx(tp);
  15.409 -}
  15.410 -
    16.1 --- a/xen-2.4.16/drivers/net/tulip/timer.c	Fri Feb 14 17:11:31 2003 +0000
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,220 +0,0 @@
    16.4 -/*
    16.5 -	drivers/net/tulip/timer.c
    16.6 -
    16.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
    16.8 -	Copyright 2000,2001  The Linux Kernel Team
    16.9 -	Written/copyright 1994-2001 by Donald Becker.
   16.10 -
   16.11 -	This software may be used and distributed according to the terms
   16.12 -	of the GNU General Public License, incorporated herein by reference.
   16.13 -
   16.14 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   16.15 -	for more information on this driver, or visit the project
   16.16 -	Web page at http://sourceforge.net/projects/tulip/
   16.17 -
   16.18 -*/
   16.19 -
   16.20 -#include "tulip.h"
   16.21 -
   16.22 -
   16.23 -void tulip_timer(unsigned long data)
   16.24 -{
   16.25 -	struct net_device *dev = (struct net_device *)data;
   16.26 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
   16.27 -	long ioaddr = dev->base_addr;
   16.28 -	u32 csr12 = inl(ioaddr + CSR12);
   16.29 -	int next_tick = 2*HZ;
   16.30 -
   16.31 -	if (tulip_debug > 2) {
   16.32 -		printk(KERN_DEBUG "%s: Media selection tick, %s, status %8.8x mode"
   16.33 -			   " %8.8x SIA %8.8x %8.8x %8.8x %8.8x.\n",
   16.34 -			   dev->name, medianame[dev->if_port], inl(ioaddr + CSR5),
   16.35 -			   inl(ioaddr + CSR6), csr12, inl(ioaddr + CSR13),
   16.36 -			   inl(ioaddr + CSR14), inl(ioaddr + CSR15));
   16.37 -	}
   16.38 -	switch (tp->chip_id) {
   16.39 -	case DC21040:
   16.40 -		if (!tp->medialock  &&  csr12 & 0x0002) { /* Network error */
   16.41 -			printk(KERN_INFO "%s: No link beat found.\n",
   16.42 -				   dev->name);
   16.43 -			dev->if_port = (dev->if_port == 2 ? 0 : 2);
   16.44 -			tulip_select_media(dev, 0);
   16.45 -			dev->trans_start = jiffies;
   16.46 -		}
   16.47 -		break;
   16.48 -	case DC21041:
   16.49 -		if (tulip_debug > 2)
   16.50 -			printk(KERN_DEBUG "%s: 21041 media tick  CSR12 %8.8x.\n",
   16.51 -				   dev->name, csr12);
   16.52 -		if (tp->medialock) break;
   16.53 -		switch (dev->if_port) {
   16.54 -		case 0: case 3: case 4:
   16.55 -		  if (csr12 & 0x0004) { /*LnkFail */
   16.56 -			/* 10baseT is dead.  Check for activity on alternate port. */
   16.57 -			tp->mediasense = 1;
   16.58 -			if (csr12 & 0x0200)
   16.59 -				dev->if_port = 2;
   16.60 -			else
   16.61 -				dev->if_port = 1;
   16.62 -			printk(KERN_INFO "%s: No 21041 10baseT link beat, Media switched to %s.\n",
   16.63 -				   dev->name, medianame[dev->if_port]);
   16.64 -			outl(0, ioaddr + CSR13); /* Reset */
   16.65 -			outl(t21041_csr14[dev->if_port], ioaddr + CSR14);
   16.66 -			outl(t21041_csr15[dev->if_port], ioaddr + CSR15);
   16.67 -			outl(t21041_csr13[dev->if_port], ioaddr + CSR13);
   16.68 -			next_tick = 10*HZ;			/* 2.4 sec. */
   16.69 -		  } else
   16.70 -			next_tick = 30*HZ;
   16.71 -		  break;
   16.72 -		case 1:					/* 10base2 */
   16.73 -		case 2:					/* AUI */
   16.74 -			if (csr12 & 0x0100) {
   16.75 -				next_tick = (30*HZ);			/* 30 sec. */
   16.76 -				tp->mediasense = 0;
   16.77 -			} else if ((csr12 & 0x0004) == 0) {
   16.78 -				printk(KERN_INFO "%s: 21041 media switched to 10baseT.\n",
   16.79 -					   dev->name);
   16.80 -				dev->if_port = 0;
   16.81 -				tulip_select_media(dev, 0);
   16.82 -				next_tick = (24*HZ)/10;				/* 2.4 sec. */
   16.83 -			} else if (tp->mediasense || (csr12 & 0x0002)) {
   16.84 -				dev->if_port = 3 - dev->if_port; /* Swap ports. */
   16.85 -				tulip_select_media(dev, 0);
   16.86 -				next_tick = 20*HZ;
   16.87 -			} else {
   16.88 -				next_tick = 20*HZ;
   16.89 -			}
   16.90 -			break;
   16.91 -		}
   16.92 -		break;
   16.93 -	case DC21140:
   16.94 -	case DC21142:
   16.95 -	case MX98713:
   16.96 -	case COMPEX9881:
   16.97 -	case DM910X:
   16.98 -	default: {
   16.99 -		struct medialeaf *mleaf;
  16.100 -		unsigned char *p;
  16.101 -		if (tp->mtable == NULL) {	/* No EEPROM info, use generic code. */
  16.102 -			/* Not much that can be done.
  16.103 -			   Assume this a generic MII or SYM transceiver. */
  16.104 -			next_tick = 60*HZ;
  16.105 -			if (tulip_debug > 2)
  16.106 -				printk(KERN_DEBUG "%s: network media monitor CSR6 %8.8x "
  16.107 -					   "CSR12 0x%2.2x.\n",
  16.108 -					   dev->name, inl(ioaddr + CSR6), csr12 & 0xff);
  16.109 -			break;
  16.110 -		}
  16.111 -		mleaf = &tp->mtable->mleaf[tp->cur_index];
  16.112 -		p = mleaf->leafdata;
  16.113 -		switch (mleaf->type) {
  16.114 -		case 0: case 4: {
  16.115 -			/* Type 0 serial or 4 SYM transceiver.  Check the link beat bit. */
  16.116 -			int offset = mleaf->type == 4 ? 5 : 2;
  16.117 -			s8 bitnum = p[offset];
  16.118 -			if (p[offset+1] & 0x80) {
  16.119 -				if (tulip_debug > 1)
  16.120 -					printk(KERN_DEBUG"%s: Transceiver monitor tick "
  16.121 -						   "CSR12=%#2.2x, no media sense.\n",
  16.122 -						   dev->name, csr12);
  16.123 -				if (mleaf->type == 4) {
  16.124 -					if (mleaf->media == 3 && (csr12 & 0x02))
  16.125 -						goto select_next_media;
  16.126 -				}
  16.127 -				break;
  16.128 -			}
  16.129 -			if (tulip_debug > 2)
  16.130 -				printk(KERN_DEBUG "%s: Transceiver monitor tick: CSR12=%#2.2x"
  16.131 -					   " bit %d is %d, expecting %d.\n",
  16.132 -					   dev->name, csr12, (bitnum >> 1) & 7,
  16.133 -					   (csr12 & (1 << ((bitnum >> 1) & 7))) != 0,
  16.134 -					   (bitnum >= 0));
  16.135 -			/* Check that the specified bit has the proper value. */
  16.136 -			if ((bitnum < 0) !=
  16.137 -				((csr12 & (1 << ((bitnum >> 1) & 7))) != 0)) {
  16.138 -				if (tulip_debug > 2)
  16.139 -					printk(KERN_DEBUG "%s: Link beat detected for %s.\n", dev->name,
  16.140 -					       medianame[mleaf->media & MEDIA_MASK]);
  16.141 -				if ((p[2] & 0x61) == 0x01)	/* Bogus Znyx board. */
  16.142 -					goto actually_mii;
  16.143 -				/* netif_carrier_on(dev); */
  16.144 -				break;
  16.145 -			}
  16.146 -			/* netif_carrier_off(dev); */
  16.147 -			if (tp->medialock)
  16.148 -				break;
  16.149 -	  select_next_media:
  16.150 -			if (--tp->cur_index < 0) {
  16.151 -				/* We start again, but should instead look for default. */
  16.152 -				tp->cur_index = tp->mtable->leafcount - 1;
  16.153 -			}
  16.154 -			dev->if_port = tp->mtable->mleaf[tp->cur_index].media;
  16.155 -			if (tulip_media_cap[dev->if_port] & MediaIsFD)
  16.156 -				goto select_next_media; /* Skip FD entries. */
  16.157 -			if (tulip_debug > 1)
  16.158 -				printk(KERN_DEBUG "%s: No link beat on media %s,"
  16.159 -				       " trying transceiver type %s.\n",
  16.160 -				       dev->name, medianame[mleaf->media & MEDIA_MASK],
  16.161 -				       medianame[tp->mtable->mleaf[tp->cur_index].media]);
  16.162 -			tulip_select_media(dev, 0);
  16.163 -			/* Restart the transmit process. */
  16.164 -			tulip_restart_rxtx(tp);
  16.165 -			next_tick = (24*HZ)/10;
  16.166 -			break;
  16.167 -		}
  16.168 -		case 1:  case 3:		/* 21140, 21142 MII */
  16.169 -		actually_mii:
  16.170 -			if (tulip_check_duplex(dev) < 0)
  16.171 -				{ /* netif_carrier_off(dev); */ }
  16.172 -			else
  16.173 -				{ /* netif_carrier_on(dev); */ }
  16.174 -			next_tick = 60*HZ;
  16.175 -			break;
  16.176 -		case 2:					/* 21142 serial block has no link beat. */
  16.177 -		default:
  16.178 -			break;
  16.179 -		}
  16.180 -	}
  16.181 -	break;
  16.182 -	}
  16.183 -	/* mod_timer synchronizes us with potential add_timer calls
  16.184 -	 * from interrupts.
  16.185 -	 */
  16.186 -	mod_timer(&tp->timer, RUN_AT(next_tick));
  16.187 -}
  16.188 -
  16.189 -
  16.190 -void mxic_timer(unsigned long data)
  16.191 -{
  16.192 -	struct net_device *dev = (struct net_device *)data;
  16.193 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  16.194 -	long ioaddr = dev->base_addr;
  16.195 -	int next_tick = 60*HZ;
  16.196 -
  16.197 -	if (tulip_debug > 3) {
  16.198 -		printk(KERN_INFO"%s: MXIC negotiation status %8.8x.\n", dev->name,
  16.199 -			   inl(ioaddr + CSR12));
  16.200 -	}
  16.201 -	if (next_tick) {
  16.202 -		mod_timer(&tp->timer, RUN_AT(next_tick));
  16.203 -	}
  16.204 -}
  16.205 -
  16.206 -
  16.207 -void comet_timer(unsigned long data)
  16.208 -{
  16.209 -	struct net_device *dev = (struct net_device *)data;
  16.210 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  16.211 -	long ioaddr = dev->base_addr;
  16.212 -	int next_tick = 60*HZ;
  16.213 -
  16.214 -	if (tulip_debug > 1)
  16.215 -		printk(KERN_DEBUG "%s: Comet link status %4.4x partner capability "
  16.216 -			   "%4.4x.\n",
  16.217 -			   dev->name, inl(ioaddr + 0xB8), inl(ioaddr + 0xC8));
  16.218 -	/* mod_timer synchronizes us with potential add_timer calls
  16.219 -	 * from interrupts.
  16.220 -	 */
  16.221 -	mod_timer(&tp->timer, RUN_AT(next_tick));
  16.222 -}
  16.223 -
    17.1 --- a/xen-2.4.16/drivers/net/tulip/tulip.h	Fri Feb 14 17:11:31 2003 +0000
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,499 +0,0 @@
    17.4 -/*
    17.5 -	drivers/net/tulip/tulip.h
    17.6 -
    17.7 -	Copyright 2000,2001  The Linux Kernel Team
    17.8 -	Written/copyright 1994-2001 by Donald Becker.
    17.9 -
   17.10 -	This software may be used and distributed according to the terms
   17.11 -	of the GNU General Public License, incorporated herein by reference.
   17.12 -
   17.13 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   17.14 -	for more information on this driver, or visit the project
   17.15 -	Web page at http://sourceforge.net/projects/tulip/
   17.16 -
   17.17 -*/
   17.18 -
   17.19 -#ifndef __NET_TULIP_H__
   17.20 -#define __NET_TULIP_H__
   17.21 -
   17.22 -#include <linux/config.h>
   17.23 -//#include <linux/kernel.h>
   17.24 -#include <linux/types.h>
   17.25 -#include <linux/spinlock.h>
   17.26 -#include <linux/netdevice.h>
   17.27 -#include <linux/timer.h>
   17.28 -#include <linux/delay.h>
   17.29 -#include <asm/io.h>
   17.30 -#include <asm/irq.h>
   17.31 -
   17.32 -
   17.33 -
   17.34 -/* undefine, or define to various debugging levels (>4 == obscene levels) */
   17.35 -#define TULIP_DEBUG 1
   17.36 -
   17.37 -/* undefine USE_IO_OPS for MMIO, define for PIO */
   17.38 -#ifdef CONFIG_TULIP_MMIO
   17.39 -# undef USE_IO_OPS
   17.40 -#else
   17.41 -# define USE_IO_OPS 1
   17.42 -#endif
   17.43 -
   17.44 -
   17.45 -
   17.46 -struct tulip_chip_table {
   17.47 -	char *chip_name;
   17.48 -	int io_size;
   17.49 -	int valid_intrs;	/* CSR7 interrupt enable settings */
   17.50 -	int flags;
   17.51 -	void (*media_timer) (unsigned long data);
   17.52 -};
   17.53 -
   17.54 -
   17.55 -enum tbl_flag {
   17.56 -	HAS_MII			= 0x0001,
   17.57 -	HAS_MEDIA_TABLE		= 0x0002,
   17.58 -	CSR12_IN_SROM		= 0x0004,
   17.59 -	ALWAYS_CHECK_MII	= 0x0008,
   17.60 -	HAS_ACPI		= 0x0010,
   17.61 -	MC_HASH_ONLY		= 0x0020, /* Hash-only multicast filter. */
   17.62 -	HAS_PNICNWAY		= 0x0080,
   17.63 -	HAS_NWAY		= 0x0040, /* Uses internal NWay xcvr. */
   17.64 -	HAS_INTR_MITIGATION	= 0x0100,
   17.65 -	IS_ASIX			= 0x0200,
   17.66 -	HAS_8023X		= 0x0400,
   17.67 -	COMET_MAC_ADDR		= 0x0800,
   17.68 -	HAS_PCI_MWI		= 0x1000,
   17.69 -};
   17.70 -
   17.71 -
   17.72 -/* chip types.  careful!  order is VERY IMPORTANT here, as these
   17.73 - * are used throughout the driver as indices into arrays */
   17.74 -/* Note 21142 == 21143. */
   17.75 -enum chips {
   17.76 -	DC21040 = 0,
   17.77 -	DC21041 = 1,
   17.78 -	DC21140 = 2,
   17.79 -	DC21142 = 3, DC21143 = 3,
   17.80 -	LC82C168,
   17.81 -	MX98713,
   17.82 -	MX98715,
   17.83 -	MX98725,
   17.84 -	AX88140,
   17.85 -	PNIC2,
   17.86 -	COMET,
   17.87 -	COMPEX9881,
   17.88 -	I21145,
   17.89 -	DM910X,
   17.90 -};
   17.91 -
   17.92 -
   17.93 -enum MediaIs {
   17.94 -	MediaIsFD = 1,
   17.95 -	MediaAlwaysFD = 2,
   17.96 -	MediaIsMII = 4,
   17.97 -	MediaIsFx = 8,
   17.98 -	MediaIs100 = 16
   17.99 -};
  17.100 -
  17.101 -
  17.102 -/* Offsets to the Command and Status Registers, "CSRs".  All accesses
  17.103 -   must be longword instructions and quadword aligned. */
  17.104 -enum tulip_offsets {
  17.105 -	CSR0 = 0,
  17.106 -	CSR1 = 0x08,
  17.107 -	CSR2 = 0x10,
  17.108 -	CSR3 = 0x18,
  17.109 -	CSR4 = 0x20,
  17.110 -	CSR5 = 0x28,
  17.111 -	CSR6 = 0x30,
  17.112 -	CSR7 = 0x38,
  17.113 -	CSR8 = 0x40,
  17.114 -	CSR9 = 0x48,
  17.115 -	CSR10 = 0x50,
  17.116 -	CSR11 = 0x58,
  17.117 -	CSR12 = 0x60,
  17.118 -	CSR13 = 0x68,
  17.119 -	CSR14 = 0x70,
  17.120 -	CSR15 = 0x78,
  17.121 -};
  17.122 -
  17.123 -/* register offset and bits for CFDD PCI config reg */
  17.124 -enum pci_cfg_driver_reg {
  17.125 -	CFDD = 0x40,
  17.126 -	CFDD_Sleep = (1 << 31),
  17.127 -	CFDD_Snooze = (1 << 30),
  17.128 -};
  17.129 -
  17.130 -
  17.131 -/* The bits in the CSR5 status registers, mostly interrupt sources. */
  17.132 -enum status_bits {
  17.133 -	TimerInt = 0x800,
  17.134 -	SytemError = 0x2000,
  17.135 -	TPLnkFail = 0x1000,
  17.136 -	TPLnkPass = 0x10,
  17.137 -	NormalIntr = 0x10000,
  17.138 -	AbnormalIntr = 0x8000,
  17.139 -	RxJabber = 0x200,
  17.140 -	RxDied = 0x100,
  17.141 -	RxNoBuf = 0x80,
  17.142 -	RxIntr = 0x40,
  17.143 -	TxFIFOUnderflow = 0x20,
  17.144 -	TxJabber = 0x08,
  17.145 -	TxNoBuf = 0x04,
  17.146 -	TxDied = 0x02,
  17.147 -	TxIntr = 0x01,
  17.148 -};
  17.149 -
  17.150 -
  17.151 -enum tulip_mode_bits {
  17.152 -	TxThreshold		= (1 << 22),
  17.153 -	FullDuplex		= (1 << 9),
  17.154 -	TxOn			= 0x2000,
  17.155 -	AcceptBroadcast		= 0x0100,
  17.156 -	AcceptAllMulticast	= 0x0080,
  17.157 -	AcceptAllPhys		= 0x0040,
  17.158 -	AcceptRunt		= 0x0008,
  17.159 -	RxOn			= 0x0002,
  17.160 -	RxTx			= (TxOn | RxOn),
  17.161 -};
  17.162 -
  17.163 -
  17.164 -enum tulip_busconfig_bits {
  17.165 -	MWI			= (1 << 24),
  17.166 -	MRL			= (1 << 23),
  17.167 -	MRM			= (1 << 21),
  17.168 -	CALShift		= 14,
  17.169 -	BurstLenShift		= 8,
  17.170 -};
  17.171 -
  17.172 -
  17.173 -/* The Tulip Rx and Tx buffer descriptors. */
  17.174 -struct tulip_rx_desc {
  17.175 -	s32 status;
  17.176 -	s32 length;
  17.177 -	u32 buffer1;
  17.178 -	u32 buffer2;
  17.179 -};
  17.180 -
  17.181 -
  17.182 -struct tulip_tx_desc {
  17.183 -	s32 status;
  17.184 -	s32 length;
  17.185 -	u32 buffer1;
  17.186 -	u32 buffer2;		/* We use only buffer 1.  */
  17.187 -};
  17.188 -
  17.189 -
  17.190 -enum desc_status_bits {
  17.191 -	DescOwned = 0x80000000,
  17.192 -	RxDescFatalErr = 0x8000,
  17.193 -	RxWholePkt = 0x0300,
  17.194 -};
  17.195 -
  17.196 -
  17.197 -enum t21041_csr13_bits {
  17.198 -	csr13_eng = (0xEF0<<4), /* for eng. purposes only, hardcode at EF0h */
  17.199 -	csr13_aui = (1<<3), /* clear to force 10bT, set to force AUI/BNC */
  17.200 -	csr13_cac = (1<<2), /* CSR13/14/15 autoconfiguration */
  17.201 -	csr13_srl = (1<<0), /* When reset, resets all SIA functions, machines */
  17.202 -
  17.203 -	csr13_mask_auibnc = (csr13_eng | csr13_aui | csr13_srl),
  17.204 -	csr13_mask_10bt = (csr13_eng | csr13_srl),
  17.205 -};
  17.206 -
  17.207 -enum t21143_csr6_bits {
  17.208 -	csr6_sc = (1<<31),
  17.209 -	csr6_ra = (1<<30),
  17.210 -	csr6_ign_dest_msb = (1<<26),
  17.211 -	csr6_mbo = (1<<25),
  17.212 -	csr6_scr = (1<<24),  /* scramble mode flag: can't be set */
  17.213 -	csr6_pcs = (1<<23),  /* Enables PCS functions (symbol mode requires csr6_ps be set) default is set */
  17.214 -	csr6_ttm = (1<<22),  /* Transmit Threshold Mode, set for 10baseT, 0 for 100BaseTX */
  17.215 -	csr6_sf = (1<<21),   /* Store and forward. If set ignores TR bits */
  17.216 -	csr6_hbd = (1<<19),  /* Heart beat disable. Disables SQE function in 10baseT */
  17.217 -	csr6_ps = (1<<18),   /* Port Select. 0 (defualt) = 10baseT, 1 = 100baseTX: can't be set */
  17.218 -	csr6_ca = (1<<17),   /* Collision Offset Enable. If set uses special algorithm in low collision situations */
  17.219 -	csr6_trh = (1<<15),  /* Transmit Threshold high bit */
  17.220 -	csr6_trl = (1<<14),  /* Transmit Threshold low bit */
  17.221 -
  17.222 -	/***************************************************************
  17.223 -	 * This table shows transmit threshold values based on media   *
  17.224 -	 * and these two registers (from PNIC1 & 2 docs) Note: this is *
  17.225 -	 * all meaningless if sf is set.                               *
  17.226 -	 ***************************************************************/
  17.227 -
  17.228 -	/***********************************
  17.229 -	 * (trh,trl) * 100BaseTX * 10BaseT *
  17.230 -	 ***********************************
  17.231 -	 *   (0,0)   *     128   *    72   *
  17.232 -	 *   (0,1)   *     256   *    96   *
  17.233 -	 *   (1,0)   *     512   *   128   *
  17.234 -	 *   (1,1)   *    1024   *   160   *
  17.235 -	 ***********************************/
  17.236 -
  17.237 -	csr6_fc = (1<<12),   /* Forces a collision in next transmission (for testing in loopback mode) */
  17.238 -	csr6_om_int_loop = (1<<10), /* internal (FIFO) loopback flag */
  17.239 -	csr6_om_ext_loop = (1<<11), /* external (PMD) loopback flag */
  17.240 -	/* set both and you get (PHY) loopback */
  17.241 -	csr6_fd = (1<<9),    /* Full duplex mode, disables hearbeat, no loopback */
  17.242 -	csr6_pm = (1<<7),    /* Pass All Multicast */
  17.243 -	csr6_pr = (1<<6),    /* Promiscuous mode */
  17.244 -	csr6_sb = (1<<5),    /* Start(1)/Stop(0) backoff counter */
  17.245 -	csr6_if = (1<<4),    /* Inverse Filtering, rejects only addresses in address table: can't be set */
  17.246 -	csr6_pb = (1<<3),    /* Pass Bad Frames, (1) causes even bad frames to be passed on */
  17.247 -	csr6_ho = (1<<2),    /* Hash-only filtering mode: can't be set */
  17.248 -	csr6_hp = (1<<0),    /* Hash/Perfect Receive Filtering Mode: can't be set */
  17.249 -
  17.250 -	csr6_mask_capture = (csr6_sc | csr6_ca),
  17.251 -	csr6_mask_defstate = (csr6_mask_capture | csr6_mbo),
  17.252 -	csr6_mask_hdcap = (csr6_mask_defstate | csr6_hbd | csr6_ps),
  17.253 -	csr6_mask_hdcaptt = (csr6_mask_hdcap  | csr6_trh | csr6_trl),
  17.254 -	csr6_mask_fullcap = (csr6_mask_hdcaptt | csr6_fd),
  17.255 -	csr6_mask_fullpromisc = (csr6_pr | csr6_pm),
  17.256 -	csr6_mask_filters = (csr6_hp | csr6_ho | csr6_if),
  17.257 -	csr6_mask_100bt = (csr6_scr | csr6_pcs | csr6_hbd),
  17.258 -};
  17.259 -
  17.260 -
  17.261 -/* Keep the ring sizes a power of two for efficiency.
  17.262 -   Making the Tx ring too large decreases the effectiveness of channel
  17.263 -   bonding and packet priority.
  17.264 -   There are no ill effects from too-large receive rings. */
  17.265 -#undef TX_RING_SIZE
  17.266 -#undef RX_RING_SIZE
  17.267 -#define TX_RING_SIZE	16
  17.268 -#define RX_RING_SIZE	32
  17.269 -
  17.270 -#define MEDIA_MASK     31
  17.271 -
  17.272 -#define PKT_BUF_SZ		1536	/* Size of each temporary Rx buffer. */
  17.273 -
  17.274 -#define TULIP_MIN_CACHE_LINE	8	/* in units of 32-bit words */
  17.275 -
  17.276 -#if defined(__sparc__) || defined(__hppa__)
  17.277 -/* The UltraSparc PCI controllers will disconnect at every 64-byte
  17.278 - * crossing anyways so it makes no sense to tell Tulip to burst
  17.279 - * any more than that.
  17.280 - */
  17.281 -#define TULIP_MAX_CACHE_LINE	16	/* in units of 32-bit words */
  17.282 -#else
  17.283 -#define TULIP_MAX_CACHE_LINE	32	/* in units of 32-bit words */
  17.284 -#endif
  17.285 -
  17.286 -
  17.287 -/* Ring-wrap flag in length field, use for last ring entry.
  17.288 -	0x01000000 means chain on buffer2 address,
  17.289 -	0x02000000 means use the ring start address in CSR2/3.
  17.290 -   Note: Some work-alike chips do not function correctly in chained mode.
  17.291 -   The ASIX chip works only in chained mode.
  17.292 -   Thus we indicates ring mode, but always write the 'next' field for
  17.293 -   chained mode as well.
  17.294 -*/
  17.295 -#define DESC_RING_WRAP 0x02000000
  17.296 -
  17.297 -
  17.298 -#define EEPROM_SIZE 128 	/* 2 << EEPROM_ADDRLEN */
  17.299 -
  17.300 -
  17.301 -#define RUN_AT(x) (jiffies + (x))
  17.302 -
  17.303 -#if defined(__i386__)			/* AKA get_unaligned() */
  17.304 -#define get_u16(ptr) (*(u16 *)(ptr))
  17.305 -#else
  17.306 -#define get_u16(ptr) (((u8*)(ptr))[0] + (((u8*)(ptr))[1]<<8))
  17.307 -#endif
  17.308 -
  17.309 -struct medialeaf {
  17.310 -	u8 type;
  17.311 -	u8 media;
  17.312 -	unsigned char *leafdata;
  17.313 -};
  17.314 -
  17.315 -
  17.316 -struct mediatable {
  17.317 -	u16 defaultmedia;
  17.318 -	u8 leafcount;
  17.319 -	u8 csr12dir;		/* General purpose pin directions. */
  17.320 -	unsigned has_mii:1;
  17.321 -	unsigned has_nonmii:1;
  17.322 -	unsigned has_reset:6;
  17.323 -	u32 csr15dir;
  17.324 -	u32 csr15val;		/* 21143 NWay setting. */
  17.325 -	struct medialeaf mleaf[0];
  17.326 -};
  17.327 -
  17.328 -
  17.329 -struct mediainfo {
  17.330 -	struct mediainfo *next;
  17.331 -	int info_type;
  17.332 -	int index;
  17.333 -	unsigned char *info;
  17.334 -};
  17.335 -
  17.336 -struct ring_info {
  17.337 -	struct sk_buff	*skb;
  17.338 -	dma_addr_t	mapping;
  17.339 -};
  17.340 -
  17.341 -
  17.342 -struct tulip_private {
  17.343 -	const char *product_name;
  17.344 -	struct net_device *next_module;
  17.345 -	struct tulip_rx_desc *rx_ring;
  17.346 -	struct tulip_tx_desc *tx_ring;
  17.347 -	dma_addr_t rx_ring_dma;
  17.348 -	dma_addr_t tx_ring_dma;
  17.349 -	/* The saved address of a sent-in-place packet/buffer, for skfree(). */
  17.350 -	struct ring_info tx_buffers[TX_RING_SIZE];
  17.351 -	/* The addresses of receive-in-place skbuffs. */
  17.352 -	struct ring_info rx_buffers[RX_RING_SIZE];
  17.353 -	u16 setup_frame[96];	/* Pseudo-Tx frame to init address table. */
  17.354 -	int chip_id;
  17.355 -	int revision;
  17.356 -	int flags;
  17.357 -	struct net_device_stats stats;
  17.358 -	struct timer_list timer;	/* Media selection timer. */
  17.359 -	u32 mc_filter[2];
  17.360 -	spinlock_t lock;
  17.361 -	spinlock_t mii_lock;
  17.362 -	unsigned int cur_rx, cur_tx;	/* The next free ring entry */
  17.363 -	unsigned int dirty_rx, dirty_tx;	/* The ring entries to be free()ed. */
  17.364 -
  17.365 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  17.366 -#define RX_A_NBF_STOP 0xffffff3f /* To disable RX and RX-NOBUF ints. */
  17.367 -        int fc_bit;
  17.368 -        int mit_sel;
  17.369 -        int mit_change; /* Signal for Interrupt Mitigtion */
  17.370 -#endif
  17.371 -	unsigned int full_duplex:1;	/* Full-duplex operation requested. */
  17.372 -	unsigned int full_duplex_lock:1;
  17.373 -	unsigned int fake_addr:1;	/* Multiport board faked address. */
  17.374 -	unsigned int default_port:4;	/* Last dev->if_port value. */
  17.375 -	unsigned int media2:4;	/* Secondary monitored media port. */
  17.376 -	unsigned int medialock:1;	/* Don't sense media type. */
  17.377 -	unsigned int mediasense:1;	/* Media sensing in progress. */
  17.378 -	unsigned int nway:1, nwayset:1;		/* 21143 internal NWay. */
  17.379 -	unsigned int csr0;	/* CSR0 setting. */
  17.380 -	unsigned int csr6;	/* Current CSR6 control settings. */
  17.381 -	unsigned char eeprom[EEPROM_SIZE];	/* Serial EEPROM contents. */
  17.382 -	void (*link_change) (struct net_device * dev, int csr5);
  17.383 -	u16 sym_advertise, mii_advertise; /* NWay capabilities advertised.  */
  17.384 -	u16 lpar;		/* 21143 Link partner ability. */
  17.385 -	u16 advertising[4];
  17.386 -	signed char phys[4], mii_cnt;	/* MII device addresses. */
  17.387 -	struct mediatable *mtable;
  17.388 -	int cur_index;		/* Current media index. */
  17.389 -	int saved_if_port;
  17.390 -	struct pci_dev *pdev;
  17.391 -	int ttimer;
  17.392 -	int susp_rx;
  17.393 -	unsigned long nir;
  17.394 -	unsigned long base_addr;
  17.395 -	int pad0, pad1;		/* Used for 8-byte alignment */
  17.396 -};
  17.397 -
  17.398 -
  17.399 -struct eeprom_fixup {
  17.400 -	char *name;
  17.401 -	unsigned char addr0;
  17.402 -	unsigned char addr1;
  17.403 -	unsigned char addr2;
  17.404 -	u16 newtable[32];	/* Max length below. */
  17.405 -};
  17.406 -
  17.407 -
  17.408 -/* 21142.c */
  17.409 -extern u16 t21142_csr14[];
  17.410 -void t21142_timer(unsigned long data);
  17.411 -void t21142_start_nway(struct net_device *dev);
  17.412 -void t21142_lnk_change(struct net_device *dev, int csr5);
  17.413 -
  17.414 -
  17.415 -/* PNIC2.c */
  17.416 -void pnic2_lnk_change(struct net_device *dev, int csr5);
  17.417 -void pnic2_timer(unsigned long data);
  17.418 -void pnic2_start_nway(struct net_device *dev);
  17.419 -void pnic2_lnk_change(struct net_device *dev, int csr5);
  17.420 -
  17.421 -/* eeprom.c */
  17.422 -void tulip_parse_eeprom(struct net_device *dev);
  17.423 -int tulip_read_eeprom(long ioaddr, int location, int addr_len);
  17.424 -
  17.425 -/* interrupt.c */
  17.426 -extern unsigned int tulip_max_interrupt_work;
  17.427 -extern int tulip_rx_copybreak;
  17.428 -void tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
  17.429 -int tulip_refill_rx(struct net_device *dev);
  17.430 -
  17.431 -/* media.c */
  17.432 -int tulip_mdio_read(struct net_device *dev, int phy_id, int location);
  17.433 -void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int value);
  17.434 -void tulip_select_media(struct net_device *dev, int startup);
  17.435 -int tulip_check_duplex(struct net_device *dev);
  17.436 -void tulip_find_mii (struct net_device *dev, int board_idx);
  17.437 -
  17.438 -/* pnic.c */
  17.439 -void pnic_do_nway(struct net_device *dev);
  17.440 -void pnic_lnk_change(struct net_device *dev, int csr5);
  17.441 -void pnic_timer(unsigned long data);
  17.442 -
  17.443 -/* timer.c */
  17.444 -void tulip_timer(unsigned long data);
  17.445 -void mxic_timer(unsigned long data);
  17.446 -void comet_timer(unsigned long data);
  17.447 -
  17.448 -/* tulip_core.c */
  17.449 -extern int tulip_debug;
  17.450 -extern const char * const medianame[];
  17.451 -extern const char tulip_media_cap[];
  17.452 -extern struct tulip_chip_table tulip_tbl[];
  17.453 -extern u8 t21040_csr13[];
  17.454 -extern u16 t21041_csr13[];
  17.455 -extern u16 t21041_csr14[];
  17.456 -extern u16 t21041_csr15[];
  17.457 -
  17.458 -#ifndef USE_IO_OPS
  17.459 -#undef inb
  17.460 -#undef inw
  17.461 -#undef inl
  17.462 -#undef outb
  17.463 -#undef outw
  17.464 -#undef outl
  17.465 -#define inb(addr) readb((void*)(addr))
  17.466 -#define inw(addr) readw((void*)(addr))
  17.467 -#define inl(addr) readl((void*)(addr))
  17.468 -#define outb(val,addr) writeb((val), (void*)(addr))
  17.469 -#define outw(val,addr) writew((val), (void*)(addr))
  17.470 -#define outl(val,addr) writel((val), (void*)(addr))
  17.471 -#endif /* !USE_IO_OPS */
  17.472 -
  17.473 -
  17.474 -
  17.475 -static inline void tulip_start_rxtx(struct tulip_private *tp)
  17.476 -{
  17.477 -	long ioaddr = tp->base_addr;
  17.478 -	outl(tp->csr6 | RxTx, ioaddr + CSR6);
  17.479 -	barrier();
  17.480 -	(void) inl(ioaddr + CSR6); /* mmio sync */
  17.481 -}
  17.482 -
  17.483 -static inline void tulip_stop_rxtx(struct tulip_private *tp)
  17.484 -{
  17.485 -	long ioaddr = tp->base_addr;
  17.486 -	u32 csr6 = inl(ioaddr + CSR6);
  17.487 -
  17.488 -	if (csr6 & RxTx) {
  17.489 -		outl(csr6 & ~RxTx, ioaddr + CSR6);
  17.490 -		barrier();
  17.491 -		(void) inl(ioaddr + CSR6); /* mmio sync */
  17.492 -	}
  17.493 -}
  17.494 -
  17.495 -static inline void tulip_restart_rxtx(struct tulip_private *tp)
  17.496 -{
  17.497 -	tulip_stop_rxtx(tp);
  17.498 -	udelay(5);
  17.499 -	tulip_start_rxtx(tp);
  17.500 -}
  17.501 -
  17.502 -#endif /* __NET_TULIP_H__ */
    18.1 --- a/xen-2.4.16/drivers/net/tulip/tulip_core.c	Fri Feb 14 17:11:31 2003 +0000
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,1925 +0,0 @@
    18.4 -/* tulip_core.c: A DEC 21x4x-family ethernet driver for Linux. */
    18.5 -
    18.6 -/*
    18.7 -	Maintained by Jeff Garzik <jgarzik@mandrakesoft.com>
    18.8 -	Copyright 2000,2001  The Linux Kernel Team
    18.9 -	Written/copyright 1994-2001 by Donald Becker.
   18.10 -
   18.11 -	This software may be used and distributed according to the terms
   18.12 -	of the GNU General Public License, incorporated herein by reference.
   18.13 -
   18.14 -	Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
   18.15 -	for more information on this driver, or visit the project
   18.16 -	Web page at http://sourceforge.net/projects/tulip/
   18.17 -
   18.18 -*/
   18.19 -
   18.20 -#define DRV_NAME	"tulip"
   18.21 -#define DRV_VERSION	"0.9.15-pre9"
   18.22 -#define DRV_RELDATE	"Nov 6, 2001"
   18.23 -
   18.24 -#include <linux/config.h>
   18.25 -#include <linux/module.h>
   18.26 -#include "tulip.h"
   18.27 -#include <linux/pci.h>
   18.28 -#include <linux/init.h>
   18.29 -#include <linux/etherdevice.h>
   18.30 -#include <linux/delay.h>
   18.31 -#include <linux/mii.h>
   18.32 -#include <linux/ethtool.h>
   18.33 -#include <asm/unaligned.h>
   18.34 -#include <asm/uaccess.h>
   18.35 -
   18.36 -#ifdef __sparc__
   18.37 -#include <asm/pbm.h>
   18.38 -#endif
   18.39 -
   18.40 -static char version[] __devinitdata =
   18.41 -	"Linux Tulip driver version " DRV_VERSION " (" DRV_RELDATE ")\n";
   18.42 -
   18.43 -
   18.44 -/* A few user-configurable values. */
   18.45 -
   18.46 -/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
   18.47 -static unsigned int max_interrupt_work = 25;
   18.48 -
   18.49 -#define MAX_UNITS 8
   18.50 -/* Used to pass the full-duplex flag, etc. */
   18.51 -static int full_duplex[MAX_UNITS];
   18.52 -static int options[MAX_UNITS];
   18.53 -static int mtu[MAX_UNITS];			/* Jumbo MTU for interfaces. */
   18.54 -
   18.55 -/*  The possible media types that can be set in options[] are: */
   18.56 -const char * const medianame[32] = {
   18.57 -	"10baseT", "10base2", "AUI", "100baseTx",
   18.58 -	"10baseT-FDX", "100baseTx-FDX", "100baseT4", "100baseFx",
   18.59 -	"100baseFx-FDX", "MII 10baseT", "MII 10baseT-FDX", "MII",
   18.60 -	"10baseT(forced)", "MII 100baseTx", "MII 100baseTx-FDX", "MII 100baseT4",
   18.61 -	"MII 100baseFx-HDX", "MII 100baseFx-FDX", "Home-PNA 1Mbps", "Invalid-19",
   18.62 -	"","","","", "","","","",  "","","","Transceiver reset",
   18.63 -};
   18.64 -
   18.65 -/* Set the copy breakpoint for the copy-only-tiny-buffer Rx structure. */
   18.66 -/*#if defined(__alpha__) || defined(__arm__) || defined(__hppa__) \
   18.67 -	|| defined(__sparc_) || defined(__ia64__) \
   18.68 -	|| defined(__sh__) || defined(__mips__)
   18.69 -static int rx_copybreak = 1518;
   18.70 -#else
   18.71 -static int rx_copybreak = 100;
   18.72 -#endif
   18.73 -*/
   18.74 -/* Xen doesn't do rx_copybreak in drivers. */
   18.75 -static int rx_copybreak = 0;
   18.76 -
   18.77 -/*
   18.78 -  Set the bus performance register.
   18.79 -	Typical: Set 16 longword cache alignment, no burst limit.
   18.80 -	Cache alignment bits 15:14	     Burst length 13:8
   18.81 -		0000	No alignment  0x00000000 unlimited		0800 8 longwords
   18.82 -		4000	8  longwords		0100 1 longword		1000 16 longwords
   18.83 -		8000	16 longwords		0200 2 longwords	2000 32 longwords
   18.84 -		C000	32  longwords		0400 4 longwords
   18.85 -	Warning: many older 486 systems are broken and require setting 0x00A04800
   18.86 -	   8 longword cache alignment, 8 longword burst.
   18.87 -	ToDo: Non-Intel setting could be better.
   18.88 -*/
   18.89 -
   18.90 -#if defined(__alpha__) || defined(__ia64__) || defined(__x86_64__)
   18.91 -static int csr0 = 0x01A00000 | 0xE000;
   18.92 -#elif defined(__i386__) || defined(__powerpc__)
   18.93 -static int csr0 = 0x01A00000 | 0x8000;
   18.94 -#elif defined(__sparc__) || defined(__hppa__)
   18.95 -/* The UltraSparc PCI controllers will disconnect at every 64-byte
   18.96 - * crossing anyways so it makes no sense to tell Tulip to burst
   18.97 - * any more than that.
   18.98 - */
   18.99 -static int csr0 = 0x01A00000 | 0x9000;
  18.100 -#elif defined(__arm__) || defined(__sh__)
  18.101 -static int csr0 = 0x01A00000 | 0x4800;
  18.102 -#else
  18.103 -#warning Processor architecture undefined!
  18.104 -static int csr0 = 0x00A00000 | 0x4800;
  18.105 -#endif
  18.106 -
  18.107 -/* Operational parameters that usually are not changed. */
  18.108 -/* Time in jiffies before concluding the transmitter is hung. */
  18.109 -#define TX_TIMEOUT  (4*HZ)
  18.110 -
  18.111 -
  18.112 -MODULE_AUTHOR("The Linux Kernel Team");
  18.113 -MODULE_DESCRIPTION("Digital 21*4* Tulip ethernet driver");
  18.114 -MODULE_LICENSE("GPL");
  18.115 -MODULE_PARM(tulip_debug, "i");
  18.116 -MODULE_PARM(max_interrupt_work, "i");
  18.117 -MODULE_PARM(rx_copybreak, "i");
  18.118 -MODULE_PARM(csr0, "i");
  18.119 -MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i");
  18.120 -MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
  18.121 -
  18.122 -#define PFX DRV_NAME ": "
  18.123 -
  18.124 -#ifdef TULIP_DEBUG
  18.125 -int tulip_debug = TULIP_DEBUG;
  18.126 -#else
  18.127 -int tulip_debug = 1;
  18.128 -#endif
  18.129 -
  18.130 -
  18.131 -
  18.132 -/*
  18.133 - * This table use during operation for capabilities and media timer.
  18.134 - *
  18.135 - * It is indexed via the values in 'enum chips'
  18.136 - */
  18.137 -
  18.138 -struct tulip_chip_table tulip_tbl[] = {
  18.139 -  /* DC21040 */
  18.140 -  { "Digital DC21040 Tulip", 128, 0x0001ebef, 0, tulip_timer },
  18.141 -
  18.142 -  /* DC21041 */
  18.143 -  { "Digital DC21041 Tulip", 128, 0x0001ebef,
  18.144 -	HAS_MEDIA_TABLE | HAS_NWAY, tulip_timer },
  18.145 -
  18.146 -  /* DC21140 */
  18.147 -  { "Digital DS21140 Tulip", 128, 0x0001ebef,
  18.148 -	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM | HAS_PCI_MWI, tulip_timer },
  18.149 -
  18.150 -  /* DC21142, DC21143 */
  18.151 -  { "Digital DS21143 Tulip", 128, 0x0801fbff,
  18.152 -	HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII | HAS_ACPI | HAS_NWAY
  18.153 -	| HAS_INTR_MITIGATION | HAS_PCI_MWI, t21142_timer },
  18.154 -
  18.155 -  /* LC82C168 */
  18.156 -  { "Lite-On 82c168 PNIC", 256, 0x0001fbef,
  18.157 -	HAS_MII | HAS_PNICNWAY, pnic_timer },
  18.158 -
  18.159 -  /* MX98713 */
  18.160 -  { "Macronix 98713 PMAC", 128, 0x0001ebef,
  18.161 -	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM, mxic_timer },
  18.162 -
  18.163 -  /* MX98715 */
  18.164 -  { "Macronix 98715 PMAC", 256, 0x0001ebef,
  18.165 -	HAS_MEDIA_TABLE, mxic_timer },
  18.166 -
  18.167 -  /* MX98725 */
  18.168 -  { "Macronix 98725 PMAC", 256, 0x0001ebef,
  18.169 -	HAS_MEDIA_TABLE, mxic_timer },
  18.170 -
  18.171 -  /* AX88140 */
  18.172 -  { "ASIX AX88140", 128, 0x0001fbff,
  18.173 -	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM | MC_HASH_ONLY
  18.174 -	| IS_ASIX, tulip_timer },
  18.175 -
  18.176 -  /* PNIC2 */
  18.177 -  { "Lite-On PNIC-II", 256, 0x0801fbff,
  18.178 -	HAS_MII | HAS_NWAY | HAS_8023X | HAS_PCI_MWI, pnic2_timer },
  18.179 -
  18.180 -  /* COMET */
  18.181 -  { "ADMtek Comet", 256, 0x0001abef,
  18.182 -	MC_HASH_ONLY | COMET_MAC_ADDR, comet_timer },
  18.183 -
  18.184 -  /* COMPEX9881 */
  18.185 -  { "Compex 9881 PMAC", 128, 0x0001ebef,
  18.186 -	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM, mxic_timer },
  18.187 -
  18.188 -  /* I21145 */
  18.189 -  { "Intel DS21145 Tulip", 128, 0x0801fbff,
  18.190 -	HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII | HAS_ACPI
  18.191 -	| HAS_NWAY | HAS_PCI_MWI, t21142_timer },
  18.192 -
  18.193 -  /* DM910X */
  18.194 -  { "Davicom DM9102/DM9102A", 128, 0x0001ebef,
  18.195 -	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM | HAS_ACPI,
  18.196 -	tulip_timer },
  18.197 -};
  18.198 -
  18.199 -
  18.200 -static struct pci_device_id tulip_pci_tbl[] __devinitdata = {
  18.201 -	{ 0x1011, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21040 },
  18.202 -	{ 0x1011, 0x0014, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21041 },
  18.203 -	{ 0x1011, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
  18.204 -	{ 0x1011, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21143 },
  18.205 -	{ 0x11AD, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, LC82C168 },
  18.206 -	{ 0x10d9, 0x0512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98713 },
  18.207 -	{ 0x10d9, 0x0531, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98715 },
  18.208 -/*	{ 0x10d9, 0x0531, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98725 },*/
  18.209 -	{ 0x125B, 0x1400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AX88140 },
  18.210 -	{ 0x11AD, 0xc115, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PNIC2 },
  18.211 -	{ 0x1317, 0x0981, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.212 -	{ 0x1317, 0x0985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.213 -	{ 0x1317, 0x1985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.214 -	{ 0x13D1, 0xAB02, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.215 -	{ 0x13D1, 0xAB03, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.216 -	{ 0x104A, 0x0981, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.217 -	{ 0x104A, 0x2774, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.218 -	{ 0x11F6, 0x9881, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMPEX9881 },
  18.219 -	{ 0x8086, 0x0039, PCI_ANY_ID, PCI_ANY_ID, 0, 0, I21145 },
  18.220 -	{ 0x1282, 0x9100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DM910X },
  18.221 -	{ 0x1282, 0x9102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DM910X },
  18.222 -	{ 0x1113, 0x1216, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.223 -	{ 0x1113, 0x1217, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98715 },
  18.224 -	{ 0x1113, 0x9511, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
  18.225 -	{ } /* terminate list */
  18.226 -};
  18.227 -MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
  18.228 -
  18.229 -
  18.230 -/* A full-duplex map for media types. */
  18.231 -const char tulip_media_cap[32] =
  18.232 -{0,0,0,16,  3,19,16,24,  27,4,7,5, 0,20,23,20,  28,31,0,0, };
  18.233 -u8 t21040_csr13[] = {2,0x0C,8,4,  4,0,0,0, 0,0,0,0, 4,0,0,0};
  18.234 -
  18.235 -/* 21041 transceiver register settings: 10-T, 10-2, AUI, 10-T, 10T-FD*/
  18.236 -u16 t21041_csr13[] = {
  18.237 -	csr13_mask_10bt,		/* 10-T */
  18.238 -	csr13_mask_auibnc,		/* 10-2 */
  18.239 -	csr13_mask_auibnc,		/* AUI */
  18.240 -	csr13_mask_10bt,		/* 10-T */
  18.241 -	csr13_mask_10bt,		/* 10T-FD */
  18.242 -};
  18.243 -u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, };
  18.244 -u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
  18.245 -
  18.246 -
  18.247 -static void tulip_tx_timeout(struct net_device *dev);
  18.248 -static void tulip_init_ring(struct net_device *dev);
  18.249 -static int tulip_start_xmit(struct sk_buff *skb, struct net_device *dev);
  18.250 -static int tulip_open(struct net_device *dev);
  18.251 -static int tulip_close(struct net_device *dev);
  18.252 -static void tulip_up(struct net_device *dev);
  18.253 -static void tulip_down(struct net_device *dev);
  18.254 -static struct net_device_stats *tulip_get_stats(struct net_device *dev);
  18.255 -static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  18.256 -static void set_rx_mode(struct net_device *dev);
  18.257 -
  18.258 -
  18.259 -
  18.260 -static void tulip_set_power_state (struct tulip_private *tp,
  18.261 -				   int sleep, int snooze)
  18.262 -{
  18.263 -	if (tp->flags & HAS_ACPI) {
  18.264 -		u32 tmp, newtmp;
  18.265 -		pci_read_config_dword (tp->pdev, CFDD, &tmp);
  18.266 -		newtmp = tmp & ~(CFDD_Sleep | CFDD_Snooze);
  18.267 -		if (sleep)
  18.268 -			newtmp |= CFDD_Sleep;
  18.269 -		else if (snooze)
  18.270 -			newtmp |= CFDD_Snooze;
  18.271 -		if (tmp != newtmp)
  18.272 -			pci_write_config_dword (tp->pdev, CFDD, newtmp);
  18.273 -	}
  18.274 -
  18.275 -}
  18.276 -
  18.277 -
  18.278 -static void tulip_up(struct net_device *dev)
  18.279 -{
  18.280 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  18.281 -	long ioaddr = dev->base_addr;
  18.282 -	int next_tick = 3*HZ;
  18.283 -	int i;
  18.284 -
  18.285 -	/* Wake the chip from sleep/snooze mode. */
  18.286 -	tulip_set_power_state (tp, 0, 0);
  18.287 -
  18.288 -	/* On some chip revs we must set the MII/SYM port before the reset!? */
  18.289 -	if (tp->mii_cnt  ||  (tp->mtable  &&  tp->mtable->has_mii))
  18.290 -		outl(0x00040000, ioaddr + CSR6);
  18.291 -
  18.292 -	/* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
  18.293 -	outl(0x00000001, ioaddr + CSR0);
  18.294 -	udelay(100);
  18.295 -
  18.296 -	/* Deassert reset.
  18.297 -	   Wait the specified 50 PCI cycles after a reset by initializing
  18.298 -	   Tx and Rx queues and the address filter list. */
  18.299 -	outl(tp->csr0, ioaddr + CSR0);
  18.300 -	udelay(100);
  18.301 -
  18.302 -	if (tulip_debug > 1)
  18.303 -		printk(KERN_DEBUG "%s: tulip_up(), irq==%d.\n", dev->name, dev->irq);
  18.304 -
  18.305 -	outl(tp->rx_ring_dma, ioaddr + CSR3);
  18.306 -	outl(tp->tx_ring_dma, ioaddr + CSR4);
  18.307 -	tp->cur_rx = tp->cur_tx = 0;
  18.308 -	tp->dirty_rx = tp->dirty_tx = 0;
  18.309 -
  18.310 -	if (tp->flags & MC_HASH_ONLY) {
  18.311 -		u32 addr_low = cpu_to_le32(get_unaligned((u32 *)dev->dev_addr));
  18.312 -		u32 addr_high = cpu_to_le32(get_unaligned((u16 *)(dev->dev_addr+4)));
  18.313 -		if (tp->chip_id == AX88140) {
  18.314 -			outl(0, ioaddr + CSR13);
  18.315 -			outl(addr_low,  ioaddr + CSR14);
  18.316 -			outl(1, ioaddr + CSR13);
  18.317 -			outl(addr_high, ioaddr + CSR14);
  18.318 -		} else if (tp->flags & COMET_MAC_ADDR) {
  18.319 -			outl(addr_low,  ioaddr + 0xA4);
  18.320 -			outl(addr_high, ioaddr + 0xA8);
  18.321 -			outl(0, ioaddr + 0xAC);
  18.322 -			outl(0, ioaddr + 0xB0);
  18.323 -		}
  18.324 -	} else {
  18.325 -		/* This is set_rx_mode(), but without starting the transmitter. */
  18.326 -		u16 *eaddrs = (u16 *)dev->dev_addr;
  18.327 -		u16 *setup_frm = &tp->setup_frame[15*6];
  18.328 -		dma_addr_t mapping;
  18.329 -
  18.330 -		/* 21140 bug: you must add the broadcast address. */
  18.331 -		memset(tp->setup_frame, 0xff, sizeof(tp->setup_frame));
  18.332 -		/* Fill the final entry of the table with our physical address. */
  18.333 -		*setup_frm++ = eaddrs[0]; *setup_frm++ = eaddrs[0];
  18.334 -		*setup_frm++ = eaddrs[1]; *setup_frm++ = eaddrs[1];
  18.335 -		*setup_frm++ = eaddrs[2]; *setup_frm++ = eaddrs[2];
  18.336 -
  18.337 -		mapping = pci_map_single(tp->pdev, tp->setup_frame,
  18.338 -					 sizeof(tp->setup_frame),
  18.339 -					 PCI_DMA_TODEVICE);
  18.340 -		tp->tx_buffers[tp->cur_tx].skb = NULL;
  18.341 -		tp->tx_buffers[tp->cur_tx].mapping = mapping;
  18.342 -
  18.343 -		/* Put the setup frame on the Tx list. */
  18.344 -		tp->tx_ring[tp->cur_tx].length = cpu_to_le32(0x08000000 | 192);
  18.345 -		tp->tx_ring[tp->cur_tx].buffer1 = cpu_to_le32(mapping);
  18.346 -		tp->tx_ring[tp->cur_tx].status = cpu_to_le32(DescOwned);
  18.347 -
  18.348 -		tp->cur_tx++;
  18.349 -	}
  18.350 -
  18.351 -	tp->saved_if_port = dev->if_port;
  18.352 -	if (dev->if_port == 0)
  18.353 -		dev->if_port = tp->default_port;
  18.354 -
  18.355 -	/* Allow selecting a default media. */
  18.356 -	i = 0;
  18.357 -	if (tp->mtable == NULL)
  18.358 -		goto media_picked;
  18.359 -	if (dev->if_port) {
  18.360 -		int looking_for = tulip_media_cap[dev->if_port] & MediaIsMII ? 11 :
  18.361 -			(dev->if_port == 12 ? 0 : dev->if_port);
  18.362 -		for (i = 0; i < tp->mtable->leafcount; i++)
  18.363 -			if (tp->mtable->mleaf[i].media == looking_for) {
  18.364 -				printk(KERN_INFO "%s: Using user-specified media %s.\n",
  18.365 -					   dev->name, medianame[dev->if_port]);
  18.366 -				goto media_picked;
  18.367 -			}
  18.368 -	}
  18.369 -	if ((tp->mtable->defaultmedia & 0x0800) == 0) {
  18.370 -		int looking_for = tp->mtable->defaultmedia & MEDIA_MASK;
  18.371 -		for (i = 0; i < tp->mtable->leafcount; i++)
  18.372 -			if (tp->mtable->mleaf[i].media == looking_for) {
  18.373 -				printk(KERN_INFO "%s: Using EEPROM-set media %s.\n",
  18.374 -					   dev->name, medianame[looking_for]);
  18.375 -				goto media_picked;
  18.376 -			}
  18.377 -	}
  18.378 -	/* Start sensing first non-full-duplex media. */
  18.379 -	for (i = tp->mtable->leafcount - 1;
  18.380 -		 (tulip_media_cap[tp->mtable->mleaf[i].media] & MediaAlwaysFD) && i > 0; i--)
  18.381 -		;
  18.382 -media_picked:
  18.383 -
  18.384 -	tp->csr6 = 0;
  18.385 -	tp->cur_index = i;
  18.386 -	tp->nwayset = 0;
  18.387 -
  18.388 -	if (dev->if_port) {
  18.389 -		if (tp->chip_id == DC21143  &&
  18.390 -		    (tulip_media_cap[dev->if_port] & MediaIsMII)) {
  18.391 -			/* We must reset the media CSRs when we force-select MII mode. */
  18.392 -			outl(0x0000, ioaddr + CSR13);
  18.393 -			outl(0x0000, ioaddr + CSR14);
  18.394 -			outl(0x0008, ioaddr + CSR15);
  18.395 -		}
  18.396 -		tulip_select_media(dev, 1);
  18.397 -	} else if (tp->chip_id == DC21041) {
  18.398 -		dev->if_port = 0;
  18.399 -		tp->nway = tp->mediasense = 1;
  18.400 -		tp->nwayset = tp->lpar = 0;
  18.401 -		outl(0x00000000, ioaddr + CSR13);
  18.402 -		outl(0xFFFFFFFF, ioaddr + CSR14);
  18.403 -		outl(0x00000008, ioaddr + CSR15); /* Listen on AUI also. */
  18.404 -		tp->csr6 = 0x80020000;
  18.405 -		if (tp->sym_advertise & 0x0040)
  18.406 -			tp->csr6 |= FullDuplex;
  18.407 -		outl(tp->csr6, ioaddr + CSR6);
  18.408 -		outl(0x0000EF01, ioaddr + CSR13);
  18.409 -
  18.410 -	} else if (tp->chip_id == DC21142) {
  18.411 -		if (tp->mii_cnt) {
  18.412 -			tulip_select_media(dev, 1);
  18.413 -			if (tulip_debug > 1)
  18.414 -				printk(KERN_INFO "%s: Using MII transceiver %d, status "
  18.415 -					   "%4.4x.\n",
  18.416 -					   dev->name, tp->phys[0], tulip_mdio_read(dev, tp->phys[0], 1));
  18.417 -			outl(csr6_mask_defstate, ioaddr + CSR6);
  18.418 -			tp->csr6 = csr6_mask_hdcap;
  18.419 -			dev->if_port = 11;
  18.420 -			outl(0x0000, ioaddr + CSR13);
  18.421 -			outl(0x0000, ioaddr + CSR14);
  18.422 -		} else
  18.423 -			t21142_start_nway(dev);
  18.424 -	} else if (tp->chip_id == PNIC2) {
  18.425 -	        /* for initial startup advertise 10/100 Full and Half */
  18.426 -	        tp->sym_advertise = 0x01E0;
  18.427 -                /* enable autonegotiate end interrupt */
  18.428 -	        outl(inl(ioaddr+CSR5)| 0x00008010, ioaddr + CSR5);
  18.429 -	        outl(inl(ioaddr+CSR7)| 0x00008010, ioaddr + CSR7);
  18.430 -		pnic2_start_nway(dev);
  18.431 -	} else if (tp->chip_id == LC82C168  &&  ! tp->medialock) {
  18.432 -		if (tp->mii_cnt) {
  18.433 -			dev->if_port = 11;
  18.434 -			tp->csr6 = 0x814C0000 | (tp->full_duplex ? 0x0200 : 0);
  18.435 -			outl(0x0001, ioaddr + CSR15);
  18.436 -		} else if (inl(ioaddr + CSR5) & TPLnkPass)
  18.437 -			pnic_do_nway(dev);
  18.438 -		else {
  18.439 -			/* Start with 10mbps to do autonegotiation. */
  18.440 -			outl(0x32, ioaddr + CSR12);
  18.441 -			tp->csr6 = 0x00420000;
  18.442 -			outl(0x0001B078, ioaddr + 0xB8);
  18.443 -			outl(0x0201B078, ioaddr + 0xB8);
  18.444 -			next_tick = 1*HZ;
  18.445 -		}
  18.446 -	} else if ((tp->chip_id == MX98713 || tp->chip_id == COMPEX9881)
  18.447 -			   && ! tp->medialock) {
  18.448 -		dev->if_port = 0;
  18.449 -		tp->csr6 = 0x01880000 | (tp->full_duplex ? 0x0200 : 0);
  18.450 -		outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
  18.451 -	} else if (tp->chip_id == MX98715 || tp->chip_id == MX98725) {
  18.452 -		/* Provided by BOLO, Macronix - 12/10/1998. */
  18.453 -		dev->if_port = 0;
  18.454 -		tp->csr6 = 0x01a80200;
  18.455 -		outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
  18.456 -		outl(0x11000 | inw(ioaddr + 0xa0), ioaddr + 0xa0);
  18.457 -	} else if (tp->chip_id == COMET) {
  18.458 -		/* Enable automatic Tx underrun recovery. */
  18.459 -		outl(inl(ioaddr + 0x88) | 1, ioaddr + 0x88);
  18.460 -		dev->if_port = tp->mii_cnt ? 11 : 0;
  18.461 -		tp->csr6 = 0x00040000;
  18.462 -	} else if (tp->chip_id == AX88140) {
  18.463 -		tp->csr6 = tp->mii_cnt ? 0x00040100 : 0x00000100;
  18.464 -	} else
  18.465 -		tulip_select_media(dev, 1);
  18.466 -
  18.467 -	/* Start the chip's Tx to process setup frame. */
  18.468 -	tulip_stop_rxtx(tp);
  18.469 -	barrier();
  18.470 -	udelay(5);
  18.471 -	outl(tp->csr6 | TxOn, ioaddr + CSR6);
  18.472 -
  18.473 -	/* Enable interrupts by setting the interrupt mask. */
  18.474 -	outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR5);
  18.475 -	outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
  18.476 -	tulip_start_rxtx(tp);
  18.477 -	outl(0, ioaddr + CSR2);		/* Rx poll demand */
  18.478 -
  18.479 -	if (tulip_debug > 2) {
  18.480 -		printk(KERN_DEBUG "%s: Done tulip_up(), CSR0 %8.8x, CSR5 %8.8x CSR6 %8.8x.\n",
  18.481 -			   dev->name, inl(ioaddr + CSR0), inl(ioaddr + CSR5),
  18.482 -			   inl(ioaddr + CSR6));
  18.483 -	}
  18.484 -
  18.485 -	/* Set the timer to switch to check for link beat and perhaps switch
  18.486 -	   to an alternate media type. */
  18.487 -	tp->timer.expires = RUN_AT(next_tick);
  18.488 -	add_timer(&tp->timer);
  18.489 -}
  18.490 -
  18.491 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  18.492 -/* Enable receiver */
  18.493 -void tulip_xon(struct net_device *dev)
  18.494 -{
  18.495 -        struct tulip_private *tp = (struct tulip_private *)dev->priv;
  18.496 -
  18.497 -        clear_bit(tp->fc_bit, &netdev_fc_xoff);
  18.498 -        if (netif_running(dev)){
  18.499 -
  18.500 -                tulip_refill_rx(dev);
  18.501 -                outl(tulip_tbl[tp->chip_id].valid_intrs,  dev->base_addr+CSR7);
  18.502 -        }
  18.503 -}
  18.504 -#endif
  18.505 -
  18.506 -static int
  18.507 -tulip_open(struct net_device *dev)
  18.508 -{
  18.509 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  18.510 -        struct tulip_private *tp = (struct tulip_private *)dev->priv;
  18.511 -#endif
  18.512 -	int retval;
  18.513 -	MOD_INC_USE_COUNT;
  18.514 -
  18.515 -	if ((retval = request_irq(dev->irq, &tulip_interrupt, SA_SHIRQ, dev->name, dev))) {
  18.516 -		MOD_DEC_USE_COUNT;
  18.517 -		return retval;
  18.518 -	}
  18.519 -
  18.520 -	tulip_init_ring (dev);
  18.521 -
  18.522 -	tulip_up (dev);
  18.523 -
  18.524 -#ifdef CONFIG_NET_HW_FLOWCONTROL
  18.525 -        tp->fc_bit = netdev_register_fc(dev, tulip_xon);
  18.526 -#endif
  18.527 -
  18.528 -	netif_start_queue (dev);
  18.529 -
  18.530 -	return 0;
  18.531 -}
  18.532 -
  18.533 -
  18.534 -static void tulip_tx_timeout(struct net_device *dev)
  18.535 -{
  18.536 -	struct tulip_private *tp = (struct tulip_private *)dev->priv;
  18.537 -	long ioaddr = dev->base_addr;
  18.538 -	unsigned long flags;
  18.539 -
  18.540 -	spin_lock_irqsave (&tp->lock, flags);
  18.541 -
  18.542 -	if (tulip_media_cap[dev->if_port] & MediaIsMII) {
  18.543 -		/* Do nothing -- the media monitor should handle this. */
  18.544 -		if (tulip_debug > 1)
  18.545 -			printk(KERN_WARNING "%s: Transmit timeout using MII device.\n",
  18.546 -				   dev->name);
  18.547 -	} else if (tp->chip_id == DC21040) {
  18.548 -		if ( !tp->medialock  &&  inl(ioaddr + CSR12) & 0x0002) {
  18.549 -			dev->if_port = (dev->if_port == 2 ? 0 : 2);
  18.550 -			printk(KERN_INFO "%s: 21040 transmit timed out, switching to "
  18.551 -				   "%s.\n",
  18.552 -				   dev->name, medianame[dev->if_port]);
  18.553 -			tulip_select_media(dev, 0);
  18.554 -		}
  18.555 -		goto out;
  18.556 -	} else if (tp->chip_id == DC21041) {
  18.557 -		int csr12 = inl(ioaddr + CSR12);
  18.558 -
  18.559 -		printk(KERN_WARNING "%s: 21041 transmit timed out, status %8.8x, "
  18.560 -			   "CSR12 %8.8x, CSR13 %8.8x, CSR14 %8.8x, resetting...\n",
  18.561 -			   dev->name, inl(ioaddr + CSR5), csr12,
  18.562 -			   inl(ioaddr + CSR13), inl(ioaddr + CSR14));
  18.563 -		tp->mediasense = 1;
  18.564 -		if ( ! tp->medialock) {
  18.565 -			if (dev->if_port == 1 || dev->if_port == 2)
  18.566 -				if (csr12 & 0x0004) {
  18.567 -					dev->if_port = 2 - dev->if_port;
  18.568 -				} else
  18.569 -					dev->if_port = 0;
  18.570 -			else
  18.571 -				dev->if_port = 1;
  18.572 -			tulip_select_media(dev, 0);
  18.573 -		}
  18.574 -	} else if (tp->chip_id == DC21140 || tp->chip_id == DC21142
  18.575 -			   || tp->chip_id == MX98713 || tp->chip_id == COMPEX9881
  18.576 -			   || tp->chip_id == DM910X) {
  18.577 -		printk(KERN_WARNING "%s: 21140 transmit timed out, status %8.8x, "
  18.578 -			   "SIA %8.8x %8.8x %8.8x %8.8x, resetting...\n",
  18.579 -			   dev->name, inl(ioaddr + CSR5), inl(ioaddr + CSR12),
  18.580 -			   inl(ioaddr + CSR13), inl(ioaddr + CSR14), inl(ioaddr + CSR15));
  18.581 -		if ( ! tp->medialock  &&  tp->mtable) {
  18.582 -			do
  18.583 -				--tp->cur_index;
  18.584 -			while (tp->cur_index >= 0
  18.585 -				   && (tulip_media_cap[tp->mtable->mleaf[tp->cur_index].media]
  18.586 -					   & MediaIsFD));
  18.587 -			if (--tp->cur_index < 0) {
  18.588 -				/* We start again, but should instead look for default. */
  18.589 -				tp->cur_index = tp->mtable->leafcount - 1;
  18.590 -			}
  18.591 -			tulip_select_media(dev, 0);
  18.592 -			printk(KERN_WARNING "%s: transmit timed out, switching to %s "
  18.593 -				   "media.\n", dev->name, medianame[dev->if_port]);
  18.594 -		}
  18.595 -	} else if (tp->chip_id == PNIC2) {
  18.596 -		printk(KERN_WARNING "%s: PNIC2 transmit timed out, status %8.8x, "
  18.597 -		       "CSR6/7 %8.8x / %8.8x CSR12 %8.8x, resetting...\n",
  18.598 -		       dev->name, (int)inl(ioaddr + CSR5), (int)inl(ioaddr + CSR6),
  18.599 -		       (int)inl(ioaddr + CSR7), (int)inl(ioaddr + CSR12));
  18.600 -	} else {
  18.601