2005-04-16 22:20:36 +00:00
|
|
|
/* 3c501.c: A 3Com 3c501 Ethernet driver for Linux. */
|
|
|
|
/*
|
|
|
|
Written 1992,1993,1994 Donald Becker
|
|
|
|
|
|
|
|
Copyright 1993 United States Government as represented by the
|
|
|
|
Director, National Security Agency. This software may be used and
|
|
|
|
distributed according to the terms of the GNU General Public License,
|
|
|
|
incorporated herein by reference.
|
|
|
|
|
|
|
|
This is a device driver for the 3Com Etherlink 3c501.
|
|
|
|
Do not purchase this card, even as a joke. It's performance is horrible,
|
|
|
|
and it breaks in many ways.
|
|
|
|
|
|
|
|
The original author may be reached as becker@scyld.com, or C/O
|
|
|
|
Scyld Computing Corporation
|
|
|
|
410 Severn Ave., Suite 210
|
|
|
|
Annapolis MD 21403
|
|
|
|
|
|
|
|
Fixed (again!) the missing interrupt locking on TX/RX shifting.
|
2008-10-14 02:01:08 +00:00
|
|
|
Alan Cox <alan@lxorguk.ukuu.org.uk>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
Removed calls to init_etherdev since they are no longer needed, and
|
|
|
|
cleaned up modularization just a bit. The driver still allows only
|
|
|
|
the default address for cards when loaded as a module, but that's
|
|
|
|
really less braindead than anyone using a 3c501 board. :)
|
|
|
|
19950208 (invid@msen.com)
|
|
|
|
|
|
|
|
Added traps for interrupts hitting the window as we clear and TX load
|
|
|
|
the board. Now getting 150K/second FTP with a 3c501 card. Still playing
|
|
|
|
with a TX-TX optimisation to see if we can touch 180-200K/second as seems
|
|
|
|
theoretically maximum.
|
2008-10-14 02:01:08 +00:00
|
|
|
19950402 Alan Cox <alan@lxorguk.ukuu.org.uk>
|
2006-09-13 17:24:59 +00:00
|
|
|
|
|
|
|
Cleaned up for 2.3.x because we broke SMP now.
|
2008-10-14 02:01:08 +00:00
|
|
|
20000208 Alan Cox <alan@lxorguk.ukuu.org.uk>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
Check up pass for 2.5. Nothing significant changed
|
2008-10-14 02:01:08 +00:00
|
|
|
20021009 Alan Cox <alan@lxorguk.ukuu.org.uk>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
Fixed zero fill corner case
|
2008-10-14 02:01:08 +00:00
|
|
|
20030104 Alan Cox <alan@lxorguk.ukuu.org.uk>
|
2006-09-13 17:24:59 +00:00
|
|
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
For the avoidance of doubt the "preferred form" of this code is one which
|
|
|
|
is in an open non patent encumbered format. Where cryptographic key signing
|
|
|
|
forms part of the process of creating an executable the information
|
|
|
|
including keys needed to generate an equivalently functional executable
|
|
|
|
are deemed to be part of the source code.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DOC: 3c501 Card Notes
|
|
|
|
*
|
|
|
|
* Some notes on this thing if you have to hack it. [Alan]
|
|
|
|
*
|
|
|
|
* Some documentation is available from 3Com. Due to the boards age
|
|
|
|
* standard responses when you ask for this will range from 'be serious'
|
|
|
|
* to 'give it to a museum'. The documentation is incomplete and mostly
|
2006-09-13 17:24:59 +00:00
|
|
|
* of historical interest anyway.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* The basic system is a single buffer which can be used to receive or
|
|
|
|
* transmit a packet. A third command mode exists when you are setting
|
|
|
|
* things up.
|
|
|
|
*
|
|
|
|
* If it's transmitting it's not receiving and vice versa. In fact the
|
|
|
|
* time to get the board back into useful state after an operation is
|
|
|
|
* quite large.
|
|
|
|
*
|
|
|
|
* The driver works by keeping the board in receive mode waiting for a
|
|
|
|
* packet to arrive. When one arrives it is copied out of the buffer
|
|
|
|
* and delivered to the kernel. The card is reloaded and off we go.
|
|
|
|
*
|
|
|
|
* When transmitting lp->txing is set and the card is reset (from
|
|
|
|
* receive mode) [possibly losing a packet just received] to command
|
|
|
|
* mode. A packet is loaded and transmit mode triggered. The interrupt
|
|
|
|
* handler runs different code for transmit interrupts and can handle
|
|
|
|
* returning to receive mode or retransmissions (yes you have to help
|
|
|
|
* out with those too).
|
|
|
|
*
|
|
|
|
* DOC: Problems
|
2006-09-13 17:24:59 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* There are a wide variety of undocumented error returns from the card
|
|
|
|
* and you basically have to kick the board and pray if they turn up. Most
|
|
|
|
* only occur under extreme load or if you do something the board doesn't
|
|
|
|
* like (eg touching a register at the wrong time).
|
|
|
|
*
|
|
|
|
* The driver is less efficient than it could be. It switches through
|
|
|
|
* receive mode even if more transmits are queued. If this worries you buy
|
|
|
|
* a real Ethernet card.
|
|
|
|
*
|
|
|
|
* The combination of slow receive restart and no real multicast
|
|
|
|
* filter makes the board unusable with a kernel compiled for IP
|
|
|
|
* multicasting in a real multicast environment. That's down to the board,
|
|
|
|
* but even with no multicast programs running a multicast IP kernel is
|
|
|
|
* in group 224.0.0.1 and you will therefore be listening to all multicasts.
|
|
|
|
* One nv conference running over that Ethernet and you can give up.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DRV_NAME "3c501"
|
|
|
|
#define DRV_VERSION "2002/10/09"
|
|
|
|
|
|
|
|
|
|
|
|
static const char version[] =
|
2008-10-14 02:01:08 +00:00
|
|
|
DRV_NAME ".c: " DRV_VERSION " Alan Cox (alan@lxorguk.ukuu.org.uk).\n";
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Braindamage remaining:
|
|
|
|
* The 3c501 board.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
#include "3c501.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The boilerplate probe code.
|
|
|
|
*/
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
static int io = 0x280;
|
|
|
|
static int irq = 5;
|
2005-04-16 22:20:36 +00:00
|
|
|
static int mem_start;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* el1_probe: - probe for a 3c501
|
2006-09-13 17:24:59 +00:00
|
|
|
* @dev: The device structure passed in to probe.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* This can be called from two places. The network layer will probe using
|
|
|
|
* a device structure passed in with the probe information completed. For a
|
|
|
|
* modular driver we use #init_module to fill in our own structure and probe
|
|
|
|
* for it.
|
|
|
|
*
|
|
|
|
* Returns 0 on success. ENXIO if asked not to probe and ENODEV if asked to
|
|
|
|
* probe and failing to find anything.
|
|
|
|
*/
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
struct net_device * __init el1_probe(int unit)
|
|
|
|
{
|
|
|
|
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
|
|
|
|
static unsigned ports[] = { 0x280, 0x300, 0};
|
|
|
|
unsigned *port;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (!dev)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
if (unit >= 0) {
|
|
|
|
sprintf(dev->name, "eth%d", unit);
|
|
|
|
netdev_boot_setup_check(dev);
|
|
|
|
io = dev->base_addr;
|
|
|
|
irq = dev->irq;
|
|
|
|
mem_start = dev->mem_start & 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (io > 0x1ff) { /* Check a single specified location. */
|
|
|
|
err = el1_probe1(dev, io);
|
|
|
|
} else if (io != 0) {
|
|
|
|
err = -ENXIO; /* Don't probe at all. */
|
|
|
|
} else {
|
|
|
|
for (port = ports; *port && el1_probe1(dev, *port); port++)
|
|
|
|
;
|
|
|
|
if (!*port)
|
|
|
|
err = -ENODEV;
|
|
|
|
}
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
err = register_netdev(dev);
|
|
|
|
if (err)
|
|
|
|
goto out1;
|
|
|
|
return dev;
|
|
|
|
out1:
|
|
|
|
release_region(dev->base_addr, EL1_IO_EXTENT);
|
|
|
|
out:
|
|
|
|
free_netdev(dev);
|
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
|
|
|
|
2009-01-09 13:01:11 +00:00
|
|
|
static const struct net_device_ops el_netdev_ops = {
|
|
|
|
.ndo_open = el_open,
|
|
|
|
.ndo_stop = el1_close,
|
|
|
|
.ndo_start_xmit = el_start_xmit,
|
|
|
|
.ndo_tx_timeout = el_timeout,
|
|
|
|
.ndo_set_multicast_list = set_multicast_list,
|
|
|
|
.ndo_change_mtu = eth_change_mtu,
|
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
2006-09-13 17:24:59 +00:00
|
|
|
* el1_probe1:
|
2005-04-16 22:20:36 +00:00
|
|
|
* @dev: The device structure to use
|
|
|
|
* @ioaddr: An I/O address to probe at.
|
|
|
|
*
|
|
|
|
* The actual probe. This is iterated over by #el1_probe in order to
|
|
|
|
* check all the applicable device locations.
|
|
|
|
*
|
|
|
|
* Returns 0 for a success, in which case the device is activated,
|
|
|
|
* EAGAIN if the IRQ is in use by another driver, and ENODEV if the
|
|
|
|
* board cannot be found.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int __init el1_probe1(struct net_device *dev, int ioaddr)
|
|
|
|
{
|
|
|
|
struct net_local *lp;
|
|
|
|
const char *mname; /* Vendor name */
|
|
|
|
unsigned char station_addr[6];
|
|
|
|
int autoirq = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reserve I/O resource for exclusive use by this driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!request_region(ioaddr, EL1_IO_EXTENT, DRV_NAME))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the station address PROM data from the special port.
|
|
|
|
*/
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
for (i = 0; i < 6; i++) {
|
2005-04-16 22:20:36 +00:00
|
|
|
outw(i, ioaddr + EL1_DATAPTR);
|
|
|
|
station_addr[i] = inb(ioaddr + EL1_SAPROM);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Check the first three octets of the S.A. for 3Com's prefix, or
|
|
|
|
* for the Sager NP943 prefix.
|
|
|
|
*/
|
|
|
|
|
2009-12-03 07:58:21 +00:00
|
|
|
if (station_addr[0] == 0x02 && station_addr[1] == 0x60 &&
|
|
|
|
station_addr[2] == 0x8c)
|
2005-04-16 22:20:36 +00:00
|
|
|
mname = "3c501";
|
2009-12-03 07:58:21 +00:00
|
|
|
else if (station_addr[0] == 0x00 && station_addr[1] == 0x80 &&
|
|
|
|
station_addr[2] == 0xC8)
|
2005-04-16 22:20:36 +00:00
|
|
|
mname = "NP943";
|
2007-11-19 15:02:32 +00:00
|
|
|
else {
|
2005-04-16 22:20:36 +00:00
|
|
|
release_region(ioaddr, EL1_IO_EXTENT);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-11-19 15:02:32 +00:00
|
|
|
* We auto-IRQ by shutting off the interrupt line and letting it
|
|
|
|
* float high.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
dev->irq = irq;
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (dev->irq < 2) {
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long irq_mask;
|
|
|
|
|
|
|
|
irq_mask = probe_irq_on();
|
|
|
|
inb(RX_STATUS); /* Clear pending interrupts. */
|
|
|
|
inb(TX_STATUS);
|
|
|
|
outb(AX_LOOP + 1, AX_CMD);
|
|
|
|
|
|
|
|
outb(0x00, AX_CMD);
|
|
|
|
|
|
|
|
mdelay(20);
|
|
|
|
autoirq = probe_irq_off(irq_mask);
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (autoirq == 0) {
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_warning("%s probe at %#x failed to detect IRQ line.\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
mname, ioaddr);
|
|
|
|
release_region(ioaddr, EL1_IO_EXTENT);
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
outb(AX_RESET+AX_LOOP, AX_CMD); /* Loopback mode. */
|
|
|
|
dev->base_addr = ioaddr;
|
|
|
|
memcpy(dev->dev_addr, station_addr, ETH_ALEN);
|
|
|
|
|
|
|
|
if (mem_start & 0xf)
|
|
|
|
el_debug = mem_start & 0x7;
|
|
|
|
if (autoirq)
|
|
|
|
dev->irq = autoirq;
|
|
|
|
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_info("%s: %s EtherLink at %#lx, using %sIRQ %d.\n",
|
2007-11-19 15:02:32 +00:00
|
|
|
dev->name, mname, dev->base_addr,
|
2005-04-16 22:20:36 +00:00
|
|
|
autoirq ? "auto":"assigned ", dev->irq);
|
|
|
|
|
|
|
|
#ifdef CONFIG_IP_MULTICAST
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_warning("WARNING: Use of the 3c501 in a multicast kernel is NOT recommended.\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (el_debug)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s", version);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
lp = netdev_priv(dev);
|
2008-11-13 07:37:49 +00:00
|
|
|
memset(lp, 0, sizeof(struct net_local));
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_lock_init(&lp->lock);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* The EL1-specific entries in the device structure.
|
|
|
|
*/
|
|
|
|
|
2009-01-09 13:01:11 +00:00
|
|
|
dev->netdev_ops = &el_netdev_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
dev->watchdog_timeo = HZ;
|
|
|
|
dev->ethtool_ops = &netdev_ethtool_ops;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* el1_open:
|
|
|
|
* @dev: device that is being opened
|
|
|
|
*
|
|
|
|
* When an ifconfig is issued which changes the device flags to include
|
2006-09-13 17:24:59 +00:00
|
|
|
* IFF_UP this function is called. It is only called when the change
|
2005-04-16 22:20:36 +00:00
|
|
|
* occurs, not when the interface remains up. #el1_close will be called
|
|
|
|
* when it goes down.
|
|
|
|
*
|
|
|
|
* Returns 0 for a successful open, or -EAGAIN if someone has run off
|
|
|
|
* with our interrupt line.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int el_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
int ioaddr = dev->base_addr;
|
|
|
|
struct net_local *lp = netdev_priv(dev);
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (el_debug > 2)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: Doing el_open()...\n", dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-11-19 07:29:17 +00:00
|
|
|
retval = request_irq(dev->irq, el_interrupt, 0, dev->name, dev);
|
2007-11-19 15:02:32 +00:00
|
|
|
if (retval)
|
2005-04-16 22:20:36 +00:00
|
|
|
return retval;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->lock, flags);
|
|
|
|
el_reset(dev);
|
|
|
|
spin_unlock_irqrestore(&lp->lock, flags);
|
|
|
|
|
|
|
|
lp->txing = 0; /* Board in RX mode */
|
|
|
|
outb(AX_RX, AX_CMD); /* Aux control, irq and receive enabled */
|
|
|
|
netif_start_queue(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* el_timeout:
|
|
|
|
* @dev: The 3c501 card that has timed out
|
|
|
|
*
|
|
|
|
* Attempt to restart the board. This is basically a mixture of extreme
|
|
|
|
* violence and prayer
|
|
|
|
*
|
|
|
|
*/
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static void el_timeout(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct net_local *lp = netdev_priv(dev);
|
|
|
|
int ioaddr = dev->base_addr;
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (el_debug)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: transmit timed out, txsr %#2x axsr=%02x rxsr=%02x.\n",
|
2007-11-19 15:02:32 +00:00
|
|
|
dev->name, inb(TX_STATUS),
|
|
|
|
inb(AX_STATUS), inb(RX_STATUS));
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
outb(TX_NORM, TX_CMD);
|
|
|
|
outb(RX_NORM, RX_CMD);
|
|
|
|
outb(AX_OFF, AX_CMD); /* Just trigger a false interrupt. */
|
|
|
|
outb(AX_RX, AX_CMD); /* Aux control, irq and receive enabled */
|
|
|
|
lp->txing = 0; /* Ripped back in to RX */
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
|
|
|
* el_start_xmit:
|
|
|
|
* @skb: The packet that is queued to be sent
|
|
|
|
* @dev: The 3c501 card we want to throw it down
|
|
|
|
*
|
|
|
|
* Attempt to send a packet to a 3c501 card. There are some interesting
|
|
|
|
* catches here because the 3c501 is an extremely old and therefore
|
|
|
|
* stupid piece of technology.
|
|
|
|
*
|
|
|
|
* If we are handling an interrupt on the other CPU we cannot load a packet
|
|
|
|
* as we may still be attempting to retrieve the last RX packet buffer.
|
|
|
|
*
|
|
|
|
* When a transmit times out we dump the card into control mode and just
|
|
|
|
* start again. It happens enough that it isnt worth logging.
|
|
|
|
*
|
|
|
|
* We avoid holding the spin locks when doing the packet load to the board.
|
|
|
|
* The device is very slow, and its DMA mode is even slower. If we held the
|
|
|
|
* lock while loading 1500 bytes onto the controller we would drop a lot of
|
|
|
|
* serial port characters. This requires we do extra locking, but we have
|
|
|
|
* no real choice.
|
|
|
|
*/
|
|
|
|
|
2009-08-31 19:50:54 +00:00
|
|
|
static netdev_tx_t el_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct net_local *lp = netdev_priv(dev);
|
|
|
|
int ioaddr = dev->base_addr;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Avoid incoming interrupts between us flipping txing and flipping
|
|
|
|
* mode as the driver assumes txing is a faithful indicator of card
|
|
|
|
* state
|
|
|
|
*/
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->lock, flags);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Avoid timer-based retransmission conflicts.
|
|
|
|
*/
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
do {
|
2005-04-16 22:20:36 +00:00
|
|
|
int len = skb->len;
|
|
|
|
int pad = 0;
|
|
|
|
int gp_start;
|
|
|
|
unsigned char *buf = skb->data;
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (len < ETH_ZLEN)
|
|
|
|
pad = ETH_ZLEN - len;
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
gp_start = 0x800 - (len + pad);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
lp->tx_pkt_start = gp_start;
|
2007-11-19 15:02:32 +00:00
|
|
|
lp->collisions = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_bytes += skb->len;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Command mode with status cleared should [in theory]
|
|
|
|
* mean no more interrupts can be pending on the card.
|
|
|
|
*/
|
|
|
|
|
|
|
|
outb_p(AX_SYS, AX_CMD);
|
|
|
|
inb_p(RX_STATUS);
|
|
|
|
inb_p(TX_STATUS);
|
|
|
|
|
|
|
|
lp->loading = 1;
|
|
|
|
lp->txing = 1;
|
|
|
|
|
|
|
|
/*
|
2007-11-19 15:02:32 +00:00
|
|
|
* Turn interrupts back on while we spend a pleasant
|
|
|
|
* afternoon loading bytes into the board
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&lp->lock, flags);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
/* Set rx packet area to 0. */
|
|
|
|
outw(0x00, RX_BUF_CLR);
|
|
|
|
/* aim - packet will be loaded into buffer start */
|
|
|
|
outw(gp_start, GP_LOW);
|
|
|
|
/* load buffer (usual thing each byte increments the pointer) */
|
|
|
|
outsb(DATAPORT, buf, len);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (pad) {
|
2007-11-19 15:02:32 +00:00
|
|
|
while (pad--) /* Zero fill buffer tail */
|
2005-04-16 22:20:36 +00:00
|
|
|
outb(0, DATAPORT);
|
|
|
|
}
|
2007-11-19 15:02:32 +00:00
|
|
|
/* the board reuses the same register */
|
|
|
|
outw(gp_start, GP_LOW);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (lp->loading != 2) {
|
|
|
|
/* fire ... Trigger xmit. */
|
|
|
|
outb(AX_XMIT, AX_CMD);
|
|
|
|
lp->loading = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
dev->trans_start = jiffies;
|
|
|
|
if (el_debug > 2)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug(" queued xmit.\n");
|
2007-11-19 15:02:32 +00:00
|
|
|
dev_kfree_skb(skb);
|
2009-07-06 02:23:38 +00:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
/* A receive upset our load, despite our best efforts */
|
2007-11-19 15:02:32 +00:00
|
|
|
if (el_debug > 2)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: burped during tx load.\n", dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_lock_irqsave(&lp->lock, flags);
|
2008-03-10 21:57:20 +00:00
|
|
|
} while (1);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* el_interrupt:
|
|
|
|
* @irq: Interrupt number
|
|
|
|
* @dev_id: The 3c501 that burped
|
|
|
|
*
|
2006-09-13 17:24:59 +00:00
|
|
|
* Handle the ether interface interrupts. The 3c501 needs a lot more
|
2005-04-16 22:20:36 +00:00
|
|
|
* hand holding than most cards. In particular we get a transmit interrupt
|
|
|
|
* with a collision error because the board firmware isnt capable of rewinding
|
|
|
|
* its own transmit buffer pointers. It can however count to 16 for us.
|
|
|
|
*
|
|
|
|
* On the receive side the card is also very dumb. It has no buffering to
|
|
|
|
* speak of. We simply pull the packet out of its PIO buffer (which is slow)
|
|
|
|
* and queue it for the kernel. Then we reset the card for the next packet.
|
|
|
|
*
|
2006-06-26 16:35:02 +00:00
|
|
|
* We sometimes get surprise interrupts late both because the SMP IRQ delivery
|
2005-04-16 22:20:36 +00:00
|
|
|
* is message passing and because the card sometimes seems to deliver late. I
|
|
|
|
* think if it is part way through a receive and the mode is changed it carries
|
|
|
|
* on receiving and sends us an interrupt. We have to band aid all these cases
|
2006-06-26 16:35:02 +00:00
|
|
|
* to get a sensible 150kBytes/second performance. Even then you want a small
|
2005-04-16 22:20:36 +00:00
|
|
|
* TCP window.
|
|
|
|
*/
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t el_interrupt(int irq, void *dev_id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct net_device *dev = dev_id;
|
|
|
|
struct net_local *lp;
|
|
|
|
int ioaddr;
|
|
|
|
int axsr; /* Aux. status reg. */
|
|
|
|
|
|
|
|
ioaddr = dev->base_addr;
|
|
|
|
lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
spin_lock(&lp->lock);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* What happened ?
|
|
|
|
*/
|
|
|
|
|
|
|
|
axsr = inb(AX_STATUS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Log it
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (el_debug > 3)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: el_interrupt() aux=%#02x\n", dev->name, axsr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (lp->loading == 1 && !lp->txing)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_warning("%s: Inconsistent state loading while not in tx\n",
|
2007-11-19 15:02:32 +00:00
|
|
|
dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (lp->txing) {
|
|
|
|
/*
|
|
|
|
* Board in transmit mode. May be loading. If we are
|
|
|
|
* loading we shouldn't have got this.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
int txsr = inb(TX_STATUS);
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (lp->loading == 1) {
|
2009-05-26 12:35:25 +00:00
|
|
|
if (el_debug > 2)
|
|
|
|
pr_debug("%s: Interrupt while loading [txsr=%02x gp=%04x rp=%04x]\n",
|
|
|
|
dev->name, txsr, inw(GP_LOW), inw(RX_LOW));
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
/* Force a reload */
|
|
|
|
lp->loading = 2;
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock(&lp->lock);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (el_debug > 6)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: txsr=%02x gp=%04x rp=%04x\n", dev->name,
|
2007-11-19 15:02:32 +00:00
|
|
|
txsr, inw(GP_LOW), inw(RX_LOW));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if ((axsr & 0x80) && (txsr & TX_READY) == 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2007-11-19 15:02:32 +00:00
|
|
|
* FIXME: is there a logic to whether to keep
|
|
|
|
* on trying or reset immediately ?
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2007-11-19 15:02:32 +00:00
|
|
|
if (el_debug > 1)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: Unusual interrupt during Tx, txsr=%02x axsr=%02x gp=%03x rp=%03x.\n",
|
2007-11-19 15:02:32 +00:00
|
|
|
dev->name, txsr, axsr,
|
|
|
|
inw(ioaddr + EL1_DATAPTR),
|
|
|
|
inw(ioaddr + EL1_RXPTR));
|
2005-04-16 22:20:36 +00:00
|
|
|
lp->txing = 0;
|
|
|
|
netif_wake_queue(dev);
|
2007-11-19 15:02:32 +00:00
|
|
|
} else if (txsr & TX_16COLLISIONS) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Timed out
|
|
|
|
*/
|
|
|
|
if (el_debug)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: Transmit failed 16 times, Ethernet jammed?\n", dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
outb(AX_SYS, AX_CMD);
|
|
|
|
lp->txing = 0;
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_aborted_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
netif_wake_queue(dev);
|
2007-11-19 15:02:32 +00:00
|
|
|
} else if (txsr & TX_COLLISION) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Retrigger xmit.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (el_debug > 6)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: retransmitting after a collision.\n", dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2007-11-19 15:02:32 +00:00
|
|
|
* Poor little chip can't reset its own start
|
|
|
|
* pointer
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
outb(AX_SYS, AX_CMD);
|
|
|
|
outw(lp->tx_pkt_start, GP_LOW);
|
|
|
|
outb(AX_XMIT, AX_CMD);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.collisions++;
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock(&lp->lock);
|
|
|
|
goto out;
|
2007-11-19 15:02:32 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* It worked.. we will now fall through and receive
|
|
|
|
*/
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_packets++;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (el_debug > 6)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: Tx succeeded %s\n", dev->name,
|
|
|
|
(txsr & TX_RDY) ? "." : "but tx is busy!");
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* This is safe the interrupt is atomic WRT itself.
|
|
|
|
*/
|
|
|
|
lp->txing = 0;
|
2007-11-19 15:02:32 +00:00
|
|
|
/* In case more to transmit */
|
|
|
|
netif_wake_queue(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-11-19 15:02:32 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* In receive mode.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
int rxsr = inb(RX_STATUS);
|
|
|
|
if (el_debug > 5)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: rxsr=%02x txsr=%02x rp=%04x\n",
|
|
|
|
dev->name, rxsr, inb(TX_STATUS), inw(RX_LOW));
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Just reading rx_status fixes most errors.
|
|
|
|
*/
|
|
|
|
if (rxsr & RX_MISSED)
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_missed_errors++;
|
2007-11-19 15:02:32 +00:00
|
|
|
else if (rxsr & RX_RUNT) {
|
|
|
|
/* Handled to avoid board lock-up. */
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_length_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (el_debug > 5)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: runt.\n", dev->name);
|
2007-11-19 15:02:32 +00:00
|
|
|
} else if (rxsr & RX_GOOD) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Receive worked.
|
|
|
|
*/
|
|
|
|
el_receive(dev);
|
2007-11-19 15:02:32 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Nothing? Something is broken!
|
|
|
|
*/
|
|
|
|
if (el_debug > 2)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: No packet seen, rxsr=%02x **resetting 3c501***\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
dev->name, rxsr);
|
|
|
|
el_reset(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move into receive mode
|
|
|
|
*/
|
|
|
|
|
|
|
|
outb(AX_RX, AX_CMD);
|
|
|
|
outw(0x00, RX_BUF_CLR);
|
|
|
|
inb(RX_STATUS); /* Be certain that interrupts are cleared. */
|
|
|
|
inb(TX_STATUS);
|
|
|
|
spin_unlock(&lp->lock);
|
|
|
|
out:
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* el_receive:
|
|
|
|
* @dev: Device to pull the packets from
|
|
|
|
*
|
|
|
|
* We have a good packet. Well, not really "good", just mostly not broken.
|
|
|
|
* We must check everything to see if it is good. In particular we occasionally
|
|
|
|
* get wild packet sizes from the card. If the packet seems sane we PIO it
|
|
|
|
* off the card and queue it for the protocol layers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void el_receive(struct net_device *dev)
|
|
|
|
{
|
|
|
|
int ioaddr = dev->base_addr;
|
|
|
|
int pkt_len;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
pkt_len = inw(RX_LOW);
|
|
|
|
|
|
|
|
if (el_debug > 4)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug(" el_receive %d.\n", pkt_len);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (pkt_len < 60 || pkt_len > 1536) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (el_debug)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_debug("%s: bogus packet, length=%d\n",
|
2008-03-10 21:57:20 +00:00
|
|
|
dev->name, pkt_len);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_over_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Command mode so we can empty the buffer
|
|
|
|
*/
|
|
|
|
|
|
|
|
outb(AX_SYS, AX_CMD);
|
|
|
|
skb = dev_alloc_skb(pkt_len+2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start of frame
|
|
|
|
*/
|
|
|
|
|
|
|
|
outw(0x00, GP_LOW);
|
2007-11-19 15:02:32 +00:00
|
|
|
if (skb == NULL) {
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_info("%s: Memory squeeze, dropping packet.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_dropped++;
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
2007-11-19 15:02:32 +00:00
|
|
|
} else {
|
|
|
|
skb_reserve(skb, 2); /* Force 16 byte alignment */
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* The read increments through the bytes. The interrupt
|
|
|
|
* handler will fix the pointer when it returns to
|
|
|
|
* receive mode.
|
|
|
|
*/
|
2007-11-19 15:02:32 +00:00
|
|
|
insb(DATAPORT, skb_put(skb, pkt_len), pkt_len);
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
netif_rx(skb);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_packets++;
|
2007-11-19 15:02:32 +00:00
|
|
|
dev->stats.rx_bytes += pkt_len;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* el_reset: Reset a 3c501 card
|
|
|
|
* @dev: The 3c501 card about to get zapped
|
|
|
|
*
|
|
|
|
* Even resetting a 3c501 isnt simple. When you activate reset it loses all
|
|
|
|
* its configuration. You must hold the lock when doing this. The function
|
|
|
|
* cannot take the lock itself as it is callable from the irq handler.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void el_reset(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct net_local *lp = netdev_priv(dev);
|
|
|
|
int ioaddr = dev->base_addr;
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (el_debug > 2)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_info("3c501 reset...\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
outb(AX_RESET, AX_CMD); /* Reset the chip */
|
2008-03-10 21:57:20 +00:00
|
|
|
/* Aux control, irq and loopback enabled */
|
|
|
|
outb(AX_LOOP, AX_CMD);
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 6; i++) /* Set the station address. */
|
|
|
|
outb(dev->dev_addr[i], ioaddr + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
outw(0, RX_BUF_CLR); /* Set rx packet area to 0. */
|
|
|
|
outb(TX_NORM, TX_CMD); /* tx irq on done, collision */
|
|
|
|
outb(RX_NORM, RX_CMD); /* Set Rx commands. */
|
|
|
|
inb(RX_STATUS); /* Clear status. */
|
|
|
|
inb(TX_STATUS);
|
|
|
|
lp->txing = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* el1_close:
|
|
|
|
* @dev: 3c501 card to shut down
|
|
|
|
*
|
|
|
|
* Close a 3c501 card. The IFF_UP flag has been cleared by the user via
|
|
|
|
* the SIOCSIFFLAGS ioctl. We stop any further transmissions being queued,
|
|
|
|
* and then disable the interrupts. Finally we reset the chip. The effects
|
|
|
|
* of the rest will be cleaned up by #el1_open. Always returns 0 indicating
|
|
|
|
* a success.
|
|
|
|
*/
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int el1_close(struct net_device *dev)
|
|
|
|
{
|
|
|
|
int ioaddr = dev->base_addr;
|
|
|
|
|
|
|
|
if (el_debug > 2)
|
2009-05-26 12:35:25 +00:00
|
|
|
pr_info("%s: Shutting down Ethernet card at %#x.\n",
|
2007-11-19 15:02:32 +00:00
|
|
|
dev->name, ioaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Free and disable the IRQ.
|
|
|
|
*/
|
|
|
|
|
|
|
|
free_irq(dev->irq, dev);
|
|
|
|
outb(AX_RESET, AX_CMD); /* Reset the chip */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set_multicast_list:
|
|
|
|
* @dev: The device to adjust
|
|
|
|
*
|
2006-09-13 17:24:59 +00:00
|
|
|
* Set or clear the multicast filter for this adaptor to use the best-effort
|
2005-04-16 22:20:36 +00:00
|
|
|
* filtering supported. The 3c501 supports only three modes of filtering.
|
|
|
|
* It always receives broadcasts and packets for itself. You can choose to
|
|
|
|
* optionally receive all packets, or all multicast packets on top of this.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void set_multicast_list(struct net_device *dev)
|
|
|
|
{
|
|
|
|
int ioaddr = dev->base_addr;
|
|
|
|
|
2007-11-19 15:02:32 +00:00
|
|
|
if (dev->flags & IFF_PROMISC) {
|
2005-04-16 22:20:36 +00:00
|
|
|
outb(RX_PROM, RX_CMD);
|
|
|
|
inb(RX_STATUS);
|
2010-02-17 23:12:15 +00:00
|
|
|
} else if (!netdev_mc_empty(dev) || dev->flags & IFF_ALLMULTI) {
|
2007-11-19 15:02:32 +00:00
|
|
|
/* Multicast or all multicast is the same */
|
|
|
|
outb(RX_MULT, RX_CMD);
|
2005-04-16 22:20:36 +00:00
|
|
|
inb(RX_STATUS); /* Clear status. */
|
2007-11-19 15:02:32 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
outb(RX_NORM, RX_CMD);
|
|
|
|
inb(RX_STATUS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void netdev_get_drvinfo(struct net_device *dev,
|
|
|
|
struct ethtool_drvinfo *info)
|
|
|
|
{
|
|
|
|
strcpy(info->driver, DRV_NAME);
|
|
|
|
strcpy(info->version, DRV_VERSION);
|
|
|
|
sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 netdev_get_msglevel(struct net_device *dev)
|
|
|
|
{
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void netdev_set_msglevel(struct net_device *dev, u32 level)
|
|
|
|
{
|
|
|
|
debug = level;
|
|
|
|
}
|
|
|
|
|
2006-09-13 18:30:00 +00:00
|
|
|
static const struct ethtool_ops netdev_ethtool_ops = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.get_drvinfo = netdev_get_drvinfo,
|
|
|
|
.get_msglevel = netdev_get_msglevel,
|
|
|
|
.set_msglevel = netdev_set_msglevel,
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
|
|
|
|
static struct net_device *dev_3c501;
|
|
|
|
|
|
|
|
module_param(io, int, 0);
|
|
|
|
module_param(irq, int, 0);
|
|
|
|
MODULE_PARM_DESC(io, "EtherLink I/O base address");
|
|
|
|
MODULE_PARM_DESC(irq, "EtherLink IRQ number");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* init_module:
|
|
|
|
*
|
|
|
|
* When the driver is loaded as a module this function is called. We fake up
|
|
|
|
* a device structure with the base I/O and interrupt set as if it were being
|
|
|
|
* called from Space.c. This minimises the extra code that would otherwise
|
|
|
|
* be required.
|
|
|
|
*
|
|
|
|
* Returns 0 for success or -EIO if a card is not found. Returning an error
|
|
|
|
* here also causes the module to be unloaded
|
|
|
|
*/
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2006-06-10 20:33:48 +00:00
|
|
|
int __init init_module(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
dev_3c501 = el1_probe(-1);
|
|
|
|
if (IS_ERR(dev_3c501))
|
|
|
|
return PTR_ERR(dev_3c501);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cleanup_module:
|
2006-09-13 17:24:59 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* The module is being unloaded. We unhook our network device from the system
|
|
|
|
* and then free up the resources we took when the card was found.
|
|
|
|
*/
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2006-06-14 22:50:53 +00:00
|
|
|
void __exit cleanup_module(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct net_device *dev = dev_3c501;
|
|
|
|
unregister_netdev(dev);
|
|
|
|
release_region(dev->base_addr, EL1_IO_EXTENT);
|
|
|
|
free_netdev(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MODULE */
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Donald Becker, Alan Cox");
|
|
|
|
MODULE_DESCRIPTION("Support for the ancient 3Com 3c501 ethernet card");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|