diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-02-23 00:40:54 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-02-23 00:40:54 +0000 |
commit | 529c593ece216e4aaffd36bd940cb94f1fa63129 (patch) | |
tree | 78f1c0b805f5656aa7b0417a043c5346f700a2cf /drivers/net/eepro.c | |
parent | 0bd079751d25808d1972baee5c4eaa1db2227257 (diff) |
Merge with 2.3.43. I did ignore all modifications to the qlogicisp.c
driver due to the Origin A64 hacks.
Diffstat (limited to 'drivers/net/eepro.c')
-rw-r--r-- | drivers/net/eepro.c | 180 |
1 files changed, 49 insertions, 131 deletions
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c index 7b988f297..21236be77 100644 --- a/drivers/net/eepro.c +++ b/drivers/net/eepro.c @@ -138,18 +138,6 @@ static const char *version = #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> - - -/* need to remove these asap */ -/* 2.1.xx compatibility macros... */ -/* */ - - -#include <linux/version.h> - -/* For linux 2.1.xx */ -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 - #include <linux/spinlock.h> #include <linux/init.h> #include <linux/delay.h> @@ -160,16 +148,6 @@ static const char *version = /* udelay(2) */ #define compat_init_data __initdata -#else -/* for 2.x */ - -#define compat_dev_kfree_skb( skb, mode ) dev_kfree_skb( (skb), (mode) ) -#define test_and_set_bit(a,b) set_bit((a),(b)) -#define SLOW_DOWN SLOW_DOWN_IO -#define compat_init_data - -#endif - /* First, a few definitions that the brave might change. */ /* A zero-terminated list of I/O addresses to be probed. */ @@ -210,9 +188,8 @@ struct eepro_local { int version; /* a flag to indicate if this is a TX or FX version of the 82595 chip. */ int stepping; -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 + spinlock_t lock; /* Serializing lock */ -#endif }; /* The station (ethernet) address prefix, used for IDing the board. */ @@ -299,6 +276,7 @@ struct eepro_local { #define ee_id_eepro10p0 0x10 /* ID for eepro/10+ */ #define ee_id_eepro10p1 0x31 +#define TX_TIMEOUT 40 /* Index to functions, as function prototypes. */ @@ -313,6 +291,7 @@ static void eepro_transmit_interrupt(struct net_device *dev); static int eepro_close(struct net_device *dev); static struct enet_statistics *eepro_get_stats(struct net_device *dev); static void set_multicast_list(struct net_device *dev); +static void eepro_tx_timeout (struct net_device *dev); static int read_eeprom(int ioaddr, int location); static void hardware_send_packet(struct net_device *dev, void *buf, short length); @@ -710,14 +689,15 @@ int eepro_probe1(struct net_device *dev, short ioaddr) return -ENOMEM; memset(dev->priv, 0, sizeof(struct eepro_local)); -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 - spin_lock_init(&(((struct eepro_local *)dev->priv)->lock)); -#endif + ((struct eepro_local *)dev->priv)->lock = SPIN_LOCK_UNLOCKED; + dev->open = eepro_open; dev->stop = eepro_close; dev->hard_start_xmit = eepro_send_packet; dev->get_stats = eepro_get_stats; dev->set_multicast_list = &set_multicast_list; + dev->tx_timeout = eepro_tx_timeout; + dev->watchdog_timeo = TX_TIMEOUT; /* Fill in the fields of the device structure with ethernet generic values */ @@ -969,10 +949,8 @@ static int eepro_open(struct net_device *dev) lp->tx_start = lp->tx_end = XMT_LOWER_LIMIT << 8; /* or = RCV_RAM */ lp->tx_last = 0; - - dev->tbusy = 0; - dev->interrupt = 0; - dev->start = 1; + + netif_start_queue(dev); if (net_debug > 3) printk(KERN_DEBUG "%s: exiting eepro_open routine.\n", dev->name); @@ -983,81 +961,53 @@ static int eepro_open(struct net_device *dev) return 0; } -static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) +static void eepro_tx_timeout (struct net_device *dev) { - struct eepro_local *lp = (struct eepro_local *)dev->priv; + struct eepro_local *lp = (struct eepro_local *) dev->priv; int ioaddr = dev->base_addr; int rcv_ram = dev->mem_end; -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 + /* if (net_debug > 1) */ + printk (KERN_ERR "%s: transmit timed out, %s?\n", dev->name, + "network cable problem"); + /* This is not a duplicate. One message for the console, + one for the the log file */ + printk (KERN_DEBUG "%s: transmit timed out, %s?\n", dev->name, + "network cable problem"); + lp->stats.tx_errors++; + + /* Try to restart the adaptor. */ + outb (SEL_RESET_CMD, ioaddr); + /* We are supposed to wait for 2 us after a SEL_RESET */ + SLOW_DOWN; + SLOW_DOWN; + + /* Do I also need to flush the transmit buffers here? YES? */ + lp->tx_start = lp->tx_end = rcv_ram; + lp->tx_last = 0; + + dev->trans_start = jiffies; + netif_start_queue (dev); + + outb (RCV_ENABLE_CMD, ioaddr); +} + + +static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) +{ + struct eepro_local *lp = (struct eepro_local *)dev->priv; unsigned long flags; -#endif if (net_debug > 5) printk(KERN_DEBUG "%s: entering eepro_send_packet routine.\n", dev->name); - if (dev->tbusy) { - /* If we get here, some higher level has decided we are broken. - There should really be a "kick me" function call instead. */ - int tickssofar = jiffies - dev->trans_start; - if (tickssofar < 40) - return 1; - - /* if (net_debug > 1) */ - printk(KERN_ERR "%s: transmit timed out, %s?\n", dev->name, - "network cable problem"); - /* This is not a duplicate. One message for the console, - one for the the log file */ - printk(KERN_DEBUG "%s: transmit timed out, %s?\n", dev->name, - "network cable problem"); - lp->stats.tx_errors++; - - /* Try to restart the adaptor. */ - outb(SEL_RESET_CMD, ioaddr); - /* We are supposed to wait for 2 us after a SEL_RESET */ - SLOW_DOWN; - SLOW_DOWN; - - /* Do I also need to flush the transmit buffers here? YES? */ - lp->tx_start = lp->tx_end = rcv_ram; - lp->tx_last = 0; - - dev->tbusy=0; - dev->trans_start = jiffies; - - outb(RCV_ENABLE_CMD, ioaddr); - - } - -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE < 0x20155 - /* If some higher layer thinks we've missed an tx-done interrupt - we are passed NULL. Caution: dev_tint() handles the cli()/sti() - itself. */ - /* if (skb == NULL) { - dev_tint(dev); - return 0; - }*/ - /* according to A. Cox, this is obsolete since 1.0 */ -#endif - -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 spin_lock_irqsave(&lp->lock, flags); -#endif - - /* Block a timer-based transmit from overlapping. */ - if (test_and_set_bit(0, (void*)&dev->tbusy) != 0) { - printk(KERN_WARNING "%s: Transmitter access conflict.\n", dev->name); -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 - spin_unlock_irqrestore(&lp->lock, flags); -#endif - } else { + { short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; unsigned char *buf = skb->data; -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 lp->stats.tx_bytes+=skb->len; -#endif hardware_send_packet(dev, buf, length); dev->trans_start = jiffies; @@ -1072,9 +1022,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) if (net_debug > 5) printk(KERN_DEBUG "%s: exiting eepro_send_packet routine.\n", dev->name); -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 spin_unlock_irqrestore(&lp->lock, flags); -#endif return 0; } @@ -1096,21 +1044,7 @@ eepro_interrupt(int irq, void *dev_id, struct pt_regs * regs) return; } -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 spin_lock(&lp->lock); -#endif - - if (dev->interrupt) { - printk(KERN_ERR "%s: Re-entering the interrupt handler.\n", dev->name); - -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 - spin_unlock(&lp->lock); - /* FIXME : with the lock, could this ever happen ? */ -#endif - - return; - } - dev->interrupt = 1; if (net_debug > 5) printk(KERN_DEBUG "%s: entering eepro_interrupt routine.\n", dev->name); @@ -1143,14 +1077,10 @@ eepro_interrupt(int irq, void *dev_id, struct pt_regs * regs) } while ((boguscount-- > 0) && (status & 0x06)); - dev->interrupt = 0; - if (net_debug > 5) printk(KERN_DEBUG "%s: exiting eepro_interrupt routine.\n", dev->name); -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 spin_unlock(&lp->lock); -#endif return; } @@ -1161,8 +1091,7 @@ static int eepro_close(struct net_device *dev) int rcv_ram = dev->mem_end; short temp_reg; - dev->tbusy = 1; - dev->start = 0; + netif_stop_queue(dev); outb(BANK1_SELECT, ioaddr); /* Switch back to Bank 1 */ @@ -1402,12 +1331,6 @@ hardware_send_packet(struct net_device *dev, void *buf, short length) service routines. */ outb(ALL_MASK, ioaddr + INT_MASK_REG); - if (dev->interrupt == 1) { - /* Enable RX and TX interrupts */ - outb(ALL_MASK & ~(RX_MASK | TX_MASK), ioaddr + INT_MASK_REG); - continue; - } - /* determine how much of the transmit buffer space is available */ if (lp->tx_end > lp->tx_start) tx_available = XMT_RAM - (lp->tx_end - lp->tx_start); @@ -1484,9 +1407,8 @@ hardware_send_packet(struct net_device *dev, void *buf, short length) lp->tx_last = last; lp->tx_end = end; - if (dev->tbusy) { - dev->tbusy = 0; - } + if (test_bit(LINK_STATE_XOFF, &dev->flags)) + netif_start_queue(dev); /* Enable RX and TX interrupts */ outb(ALL_MASK & ~(RX_MASK | TX_MASK), ioaddr + INT_MASK_REG); @@ -1496,7 +1418,7 @@ hardware_send_packet(struct net_device *dev, void *buf, short length) return; } - dev->tbusy = 1; + netif_stop_queue(dev); if (net_debug > 5) printk(KERN_DEBUG "%s: exiting hardware_send_packet routine.\n", dev->name); } @@ -1529,9 +1451,7 @@ eepro_rx(struct net_device *dev) /* Malloc up new buffer. */ struct sk_buff *skb; -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 lp->stats.rx_bytes+=rcv_size; -#endif rcv_size &= 0x3fff; skb = dev_alloc_skb(rcv_size+5); if (skb == NULL) { @@ -1622,8 +1542,7 @@ eepro_transmit_interrupt(struct net_device *dev) xmt_status = inw(ioaddr+IO_PORT); lp->tx_start = inw(ioaddr+IO_PORT); - dev->tbusy = 0; - mark_bh(NET_BH); + netif_wake_queue (dev); if (xmt_status & 0x2000) lp->stats.tx_packets++; @@ -1650,8 +1569,6 @@ eepro_transmit_interrupt(struct net_device *dev) } } -#ifdef MODULE - #define MAX_EEPRO 8 static char devicename[MAX_EEPRO][9]; static struct net_device dev_eepro[MAX_EEPRO]; @@ -1670,13 +1587,14 @@ static int mem[MAX_EEPRO] = { /* Size of the rx buffer in KB */ static int n_eepro = 0; /* For linux 2.1.xx */ -#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x20155 + MODULE_AUTHOR("Pascal Dupuis <dupuis@lei.ucl.ac.be> for the 2.1 stuff (locking,...)"); MODULE_DESCRIPTION("Intel i82595 ISA EtherExpressPro10/10+ driver"); MODULE_PARM(io, "1-" __MODULE_STRING(MAX_EEPRO) "i"); MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_EEPRO) "i"); MODULE_PARM(mem, "1-" __MODULE_STRING(MAX_EEPRO) "i"); -#endif + +#ifdef MODULE int init_module(void) |