Commit 2d8ead33 authored by Linus Torvalds's avatar Linus Torvalds

Import 1.1.50

parent 83879d61
VERSION = 1 VERSION = 1
PATCHLEVEL = 1 PATCHLEVEL = 1
SUBLEVEL = 49 SUBLEVEL = 50
ARCH = i386 ARCH = i386
......
...@@ -25,7 +25,6 @@ bool 'Assume subnets are local' CONFIG_INET_SNARL y ...@@ -25,7 +25,6 @@ bool 'Assume subnets are local' CONFIG_INET_SNARL y
bool 'Disable NAGLE algorithm (normally enabled)' CONFIG_TCP_NAGLE_OFF n bool 'Disable NAGLE algorithm (normally enabled)' CONFIG_TCP_NAGLE_OFF n
fi fi
bool 'The IPX protocol' CONFIG_IPX n bool 'The IPX protocol' CONFIG_IPX n
bool 'RPC connections to old BSD systems' CONFIG_I_AM_A_BROKEN_BSD_WEENIE n
#bool 'Amateur Radio AX.25 Level 2' CONFIG_AX25 n #bool 'Amateur Radio AX.25 Level 2' CONFIG_AX25 n
fi fi
......
...@@ -232,7 +232,7 @@ static void make_request(int major,int rw, struct buffer_head * bh) ...@@ -232,7 +232,7 @@ static void make_request(int major,int rw, struct buffer_head * bh)
|| major == SCSI_CDROM_MAJOR) || major == SCSI_CDROM_MAJOR)
&& (req = blk_dev[major].current_request)) && (req = blk_dev[major].current_request))
{ {
if (major == HD_MAJOR) if (major == HD_MAJOR || major == FLOPPY_MAJOR)
req = req->next; req = req->next;
while (req) { while (req) {
if (req->dev == bh->b_dev && if (req->dev == bh->b_dev &&
......
...@@ -69,6 +69,7 @@ static XD_SIGNATURE xd_sigs[] = { ...@@ -69,6 +69,7 @@ static XD_SIGNATURE xd_sigs[] = {
{ 0x0008,"06/24/88(C) Copyright 1988 Western Digital Corp.",xd_wd_init_controller,xd_wd_init_drive," Western Digital WDXT-GEN2" }, /* Dan Newcombe, newcombe@aa.csc.peachnet.edu */ { 0x0008,"06/24/88(C) Copyright 1988 Western Digital Corp.",xd_wd_init_controller,xd_wd_init_drive," Western Digital WDXT-GEN2" }, /* Dan Newcombe, newcombe@aa.csc.peachnet.edu */
{ 0x0015,"SEAGATE ST11 BIOS REVISION",xd_seagate_init_controller,xd_seagate_init_drive," Seagate ST11M/R" }, /* Salvador Abreu, spa@fct.unl.pt */ { 0x0015,"SEAGATE ST11 BIOS REVISION",xd_seagate_init_controller,xd_seagate_init_drive," Seagate ST11M/R" }, /* Salvador Abreu, spa@fct.unl.pt */
{ 0x0010,"ST11R BIOS",xd_seagate_init_controller,xd_seagate_init_drive," Seagate ST11M/R" }, /* Risto Kankkunen, risto.kankkunen@cs.helsinki.fi */ { 0x0010,"ST11R BIOS",xd_seagate_init_controller,xd_seagate_init_drive," Seagate ST11M/R" }, /* Risto Kankkunen, risto.kankkunen@cs.helsinki.fi */
{ 0x0010,"ST11 BIOS V1.7",xd_seagate_init_controller,xd_seagate_init_drive," Seagate ST11R" }, /* Alan Hourihane, alanh@fairlite.demon.co.uk */
{ 0x1000,"(c)Copyright 1987 SMS",xd_omti_init_controller,xd_omti_init_drive,"n OMTI 5520" }, /* Dirk Melchers, dirk@merlin.nbg.sub.org */ { 0x1000,"(c)Copyright 1987 SMS",xd_omti_init_controller,xd_omti_init_drive,"n OMTI 5520" }, /* Dirk Melchers, dirk@merlin.nbg.sub.org */
}; };
static u_char *xd_bases[] = static u_char *xd_bases[] =
......
...@@ -237,7 +237,9 @@ el_open(struct device *dev) ...@@ -237,7 +237,9 @@ el_open(struct device *dev)
static int static int
el_start_xmit(struct sk_buff *skb, struct device *dev) el_start_xmit(struct sk_buff *skb, struct device *dev)
{ {
unsigned long flags;
save_flags(flags);
if (dev->tbusy) { if (dev->tbusy) {
if (jiffies - dev->trans_start < 20) { if (jiffies - dev->trans_start < 20) {
if (el_debug > 2) if (el_debug > 2)
...@@ -251,12 +253,14 @@ el_start_xmit(struct sk_buff *skb, struct device *dev) ...@@ -251,12 +253,14 @@ el_start_xmit(struct sk_buff *skb, struct device *dev)
#ifdef oldway #ifdef oldway
el_reset(dev); el_reset(dev);
#else #else
cli();
outb(TX_NORM, TX_CMD); outb(TX_NORM, TX_CMD);
outb(RX_NORM, RX_CMD); outb(RX_NORM, RX_CMD);
outb(AX_OFF, AX_CMD); /* Just trigger a false interrupt. */ outb(AX_OFF, AX_CMD); /* Just trigger a false interrupt. */
#endif #endif
outb(AX_RX, AX_CMD); /* Aux control, irq and receive enabled */ outb(AX_RX, AX_CMD); /* Aux control, irq and receive enabled */
dev->tbusy = 0; dev->tbusy = 0;
restore_flags(flags);
dev->trans_start = jiffies; dev->trans_start = jiffies;
} }
...@@ -269,9 +273,12 @@ el_start_xmit(struct sk_buff *skb, struct device *dev) ...@@ -269,9 +273,12 @@ el_start_xmit(struct sk_buff *skb, struct device *dev)
return 0; return 0;
/* Avoid timer-based retransmission conflicts. */ /* Avoid timer-based retransmission conflicts. */
cli();
if (set_bit(0, (void*)&dev->tbusy) != 0) if (set_bit(0, (void*)&dev->tbusy) != 0)
{
printk("%s: Transmitter access conflict.\n", dev->name); printk("%s: Transmitter access conflict.\n", dev->name);
else { restore_flags(flags);
} else {
int gp_start = 0x800 - (ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN); int gp_start = 0x800 - (ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN);
unsigned char *buf = skb->data; unsigned char *buf = skb->data;
...@@ -283,6 +290,7 @@ el_start_xmit(struct sk_buff *skb, struct device *dev) ...@@ -283,6 +290,7 @@ el_start_xmit(struct sk_buff *skb, struct device *dev)
inb(TX_STATUS); inb(TX_STATUS);
outb(0x00, RX_BUF_CLR); /* Set rx packet area to 0. */ outb(0x00, RX_BUF_CLR); /* Set rx packet area to 0. */
outw(gp_start, GP_LOW); outw(gp_start, GP_LOW);
restore_flags(flags);
outsb(DATAPORT,buf,skb->len); outsb(DATAPORT,buf,skb->len);
outw(gp_start, GP_LOW); outw(gp_start, GP_LOW);
outb(AX_XMIT, AX_CMD); /* Trigger xmit. */ outb(AX_XMIT, AX_CMD); /* Trigger xmit. */
......
/* lance.c: An AMD LANCE ethernet driver for linux. */ /* lance.c: An AMD LANCE ethernet driver for linux. */
/* /*
Written 1993 by Donald Becker. Written 1993-94 by Donald Becker.
Copyright 1993 United States Government as represented by the Copyright 1993 United States Government as represented by the
Director, National Security Agency. This software may be used and Director, National Security Agency.
distributed according to the terms of the GNU Public License, This software may be used and distributed according to the terms
incorporated herein by reference. of the GNU Public License, incorporated herein by reference.
This driver is for the Allied Telesis AT1500 and HP J2405A, and should work This driver is for the Allied Telesis AT1500 and HP J2405A, and should work
with most other LANCE-based bus-master (NE2100 clone) ethercards. with most other LANCE-based bus-master (NE2100 clone) ethercards.
The author may be reached as becker@super.org or The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O
C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715 Center of Excellence in Space Data and Information Sciences
Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
*/ */
static char *version = "lance.c:v0.14g 12/21/93 becker@super.org\n"; static char *version = "lance.c:v1.01 8/31/94 becker@cesdis.gsfc.nasa.gov\n";
#include <linux/config.h> #include <linux/config.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -33,13 +34,15 @@ static char *version = "lance.c:v0.14g 12/21/93 becker@super.org\n"; ...@@ -33,13 +34,15 @@ static char *version = "lance.c:v0.14g 12/21/93 becker@super.org\n";
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#ifndef HAVE_PORTRESERVE
#define check_region(addr, size) 0
#define snarf_region(addr, size) do ; while(0)
#endif
struct device *init_etherdev(struct device *dev, int sizeof_private, struct device *init_etherdev(struct device *dev, int sizeof_private,
unsigned long *mem_startp); unsigned long *mem_startp);
static unsigned int lance_portlist[] = {0x300, 0x320, 0x340, 0x360, 0};
unsigned long lance_probe1(short ioaddr, unsigned long mem_start);
#ifdef HAVE_DEVLIST
struct netdev_entry lance_drv =
{"lance", lance_probe1, LANCE_TOTAL_SIZE, lance_portlist};
#endif
#ifdef LANCE_DEBUG #ifdef LANCE_DEBUG
int lance_debug = LANCE_DEBUG; int lance_debug = LANCE_DEBUG;
...@@ -47,12 +50,8 @@ int lance_debug = LANCE_DEBUG; ...@@ -47,12 +50,8 @@ int lance_debug = LANCE_DEBUG;
int lance_debug = 1; int lance_debug = 1;
#endif #endif
#ifndef LANCE_DMA
#define LANCE_DMA 5
#endif
/* /*
Theory of Operation Theory of Operation
I. Board Compatibility I. Board Compatibility
...@@ -60,36 +59,40 @@ This device driver is designed for the AMD 79C960, the "PCnet-ISA ...@@ -60,36 +59,40 @@ This device driver is designed for the AMD 79C960, the "PCnet-ISA
single-chip ethernet controller for ISA". This chip is used in a wide single-chip ethernet controller for ISA". This chip is used in a wide
variety of boards from vendors such as Allied Telesis, HP, Kingston, variety of boards from vendors such as Allied Telesis, HP, Kingston,
and Boca. This driver is also intended to work with older AMD 7990 and Boca. This driver is also intended to work with older AMD 7990
designs, such as the NE1500 and NE2100. For convenience, I use the name designs, such as the NE1500 and NE2100, and newer 79C961. For convenience,
LANCE to refer to either AMD chip. I use the name LANCE to refer to all of the AMD chips, even though it properly
refers only to the original 7990.
II. Board-specific settings II. Board-specific settings
The driver is designed to work the boards that use the faster The driver is designed to work the boards that use the faster
bus-master mode, rather than in shared memory mode. (Only older designs bus-master mode, rather than in shared memory mode. (Only older designs
have on-board buffer memory needed to support the slower shared memory mode.) have on-board buffer memory needed to support the slower shared memory mode.)
Most boards have jumpered settings for the I/O base, IRQ line, and DMA channel. Most ISA boards have jumpered settings for the I/O base, IRQ line, and DMA
This driver probes the likely base addresses, {0x300, 0x320, 0x340, 0x360}. channel. This driver probes the likely base addresses:
{0x300, 0x320, 0x340, 0x360}.
After the board is found it generates an DMA-timeout interrupt and uses After the board is found it generates an DMA-timeout interrupt and uses
autoIRQ to find the IRQ line. The DMA channel defaults to LANCE_DMA, or it autoIRQ to find the IRQ line. The DMA channel can be set with the low bits
can be set with the low bits of the otherwise-unused dev->mem_start value. of the otherwise-unused dev->mem_start value (aka PARAM1). If unset it is
probed for by enabling each free DMA channel in turn and checking if
initialization succeeds.
The HP-J2405A board is an exception: with this board it's easy to read the The HP-J2405A board is an exception: with this board it's easy to read the
EEPROM-set values for the base, IRQ, and DMA. Of course you must already EEPROM-set values for the base, IRQ, and DMA. (Of course you must already
_know_ the base address, but that entry is for changing the EEPROM. _know_ the base address -- that field is for writing the EEPROM.)
III. Driver operation III. Driver operation
IIIa. Ring buffers IIIa. Ring buffers
The LANCE uses ring buffers of Tx and Rx descriptors. Each entry describes The LANCE uses ring buffers of Tx and Rx descriptors. Each entry describes
the base and length of the data buffer, along with status bits. The length the base and length of the data buffer, along with status bits. The length
of these buffers is set by LANCE_LOG_{RX,TX}_BUFFERS, which is log_2() of of these buffers is set by LANCE_LOG_{RX,TX}_BUFFERS, which is log_2() of
the buffer length (rather than being directly the buffer length) for the buffer length (rather than being directly the buffer length) for
implementation ease. The current values are 2 (Tx) and 4 (Rx), which leads to implementation ease. The current values are 2 (Tx) and 4 (Rx), which leads to
ring sizes of 4 (Tx) and 16 (Rx). Increasing the number of ring entries ring sizes of 4 (Tx) and 16 (Rx). Increasing the number of ring entries
needlessly uses extra space and reduces the chance that an upper layer will needlessly uses extra space and reduces the chance that an upper layer will
be able to reorder queued Tx packets based on priority. Decreasing the number be able to reorder queued Tx packets based on priority. Decreasing the number
of entries makes it more difficult to achieve back-to-back packet transmission of entries makes it more difficult to achieve back-to-back packet transmission
and increases the chance that Rx ring will overflow. (Consider the worst case and increases the chance that Rx ring will overflow. (Consider the worst case
of receiving back-to-back minimum-sized packets.) of receiving back-to-back minimum-sized packets.)
...@@ -106,10 +109,10 @@ the buffers are only used when needed as low-memory bounce buffers. ...@@ -106,10 +109,10 @@ the buffers are only used when needed as low-memory bounce buffers.
IIIB. 16M memory limitations. IIIB. 16M memory limitations.
For the ISA bus master mode all structures used directly by the LANCE, For the ISA bus master mode all structures used directly by the LANCE,
the initialization block, Rx and Tx rings, and data buffers, must be the initialization block, Rx and Tx rings, and data buffers, must be
accessible from the ISA bus, i.e. in the lower 16M of real memory. accessable from the ISA bus, i.e. in the lower 16M of real memory.
This is a problem for current Linux kernels on >16M machines. The network This is a problem for current Linux kernels on >16M machines. The network
devices are initialized after memory initialization, and the kernel doles out devices are initialized after memory initialization, and the kernel doles out
memory from the top of memory downward. The current solution is to have a memory from the top of memory downward. The current solution is to have a
special network initialization routine that's called before memory special network initialization routine that's called before memory
initialization; this will eventually be generalized for all network devices. initialization; this will eventually be generalized for all network devices.
As mentioned before, low-memory "bounce-buffers" are used when needed. As mentioned before, low-memory "bounce-buffers" are used when needed.
...@@ -128,8 +131,8 @@ the 'lp->tx_full' flag. ...@@ -128,8 +131,8 @@ the 'lp->tx_full' flag.
The interrupt handler has exclusive control over the Rx ring and records stats The interrupt handler has exclusive control over the Rx ring and records stats
from the Tx ring. (The Tx-done interrupt can't be selectively turned off, so from the Tx ring. (The Tx-done interrupt can't be selectively turned off, so
we can't avoid the interrupt overhead by having the Tx routine reap the Tx we can't avoid the interrupt overhead by having the Tx routine reap the Tx
stats.) After reaping the stats, it marks the queue entry as empty by setting stats.) After reaping the stats, it marks the queue entry as empty by setting
the 'base' to zero. Iff the 'lp->tx_full' flag is set, it clears both the the 'base' to zero. Iff the 'lp->tx_full' flag is set, it clears both the
tx_full and tbusy flags. tx_full and tbusy flags.
*/ */
...@@ -142,15 +145,15 @@ tx_full and tbusy flags. ...@@ -142,15 +145,15 @@ tx_full and tbusy flags.
#define LANCE_LOG_RX_BUFFERS 4 #define LANCE_LOG_RX_BUFFERS 4
#endif #endif
#define TX_RING_SIZE (1 << (LANCE_LOG_TX_BUFFERS)) #define TX_RING_SIZE (1 << (LANCE_LOG_TX_BUFFERS))
#define TX_RING_MOD_MASK (TX_RING_SIZE - 1) #define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
#define TX_RING_LEN_BITS ((LANCE_LOG_TX_BUFFERS) << 29) #define TX_RING_LEN_BITS ((LANCE_LOG_TX_BUFFERS) << 29)
#define RX_RING_SIZE (1 << (LANCE_LOG_RX_BUFFERS)) #define RX_RING_SIZE (1 << (LANCE_LOG_RX_BUFFERS))
#define RX_RING_MOD_MASK (RX_RING_SIZE - 1) #define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
#define RX_RING_LEN_BITS ((LANCE_LOG_RX_BUFFERS) << 29) #define RX_RING_LEN_BITS ((LANCE_LOG_RX_BUFFERS) << 29)
#define PKT_BUF_SZ 1544 #define PKT_BUF_SZ 1544
/* Offsets from base I/O address. */ /* Offsets from base I/O address. */
#define LANCE_DATA 0x10 #define LANCE_DATA 0x10
...@@ -161,46 +164,64 @@ tx_full and tbusy flags. ...@@ -161,46 +164,64 @@ tx_full and tbusy flags.
/* The LANCE Rx and Tx ring descriptors. */ /* The LANCE Rx and Tx ring descriptors. */
struct lance_rx_head { struct lance_rx_head {
int base; int base;
short buf_length; /* This length is 2's complement (negative)! */ short buf_length; /* This length is 2s complement (negative)! */
short msg_length; /* This length is "normal". */ short msg_length; /* This length is "normal". */
}; };
struct lance_tx_head { struct lance_tx_head {
int base; int base;
short length; /* Length is 2's complement (negative)! */ short length; /* Length is 2s complement (negative)! */
short misc; short misc;
}; };
/* The LANCE initialization block, described in databook. */ /* The LANCE initialization block, described in databook. */
struct lance_init_block { struct lance_init_block {
unsigned short mode; /* Pre-set mode (reg. 15) */ unsigned short mode; /* Pre-set mode (reg. 15) */
unsigned char phys_addr[6]; /* Physical ethernet address */ unsigned char phys_addr[6]; /* Physical ethernet address */
unsigned filter[2]; /* Multicast filter (unused). */ unsigned filter[2]; /* Multicast filter (unused). */
/* Receive and transmit ring base, along with extra bits. */ /* Receive and transmit ring base, along with extra bits. */
unsigned rx_ring; /* Tx and Rx ring base pointers */ unsigned rx_ring; /* Tx and Rx ring base pointers */
unsigned tx_ring; unsigned tx_ring;
}; };
struct lance_private { struct lance_private {
char devname[8]; char devname[8];
/* These must aligned on 8-byte boundaries. */ /* The Tx and Rx ring entries must aligned on 8-byte boundaries. */
struct lance_rx_head rx_ring[RX_RING_SIZE]; struct lance_rx_head rx_ring[RX_RING_SIZE];
struct lance_tx_head tx_ring[TX_RING_SIZE]; struct lance_tx_head tx_ring[TX_RING_SIZE];
struct lance_init_block init_block; struct lance_init_block init_block;
long rx_buffs; /* Address of Rx and Tx buffers. */ /* The saved address of a sent-in-place packet/buffer, for skfree(). */
/* Tx low-memory "bounce buffer" address. */ struct sk_buff* tx_skbuff[TX_RING_SIZE];
char (*tx_bounce_buffs)[PKT_BUF_SZ]; long rx_buffs; /* Address of Rx and Tx buffers. */
int cur_rx, cur_tx; /* The next free ring entry */ /* Tx low-memory "bounce buffer" address. */
int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */ char (*tx_bounce_buffs)[PKT_BUF_SZ];
int dma; int cur_rx, cur_tx; /* The next free ring entry */
struct enet_statistics stats; int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */
char old_lance; int dma;
char lock; struct enet_statistics stats;
int pad0, pad1; /* Used for alignment */ char chip_version; /* See lance_chip_type. */
char tx_full;
char lock;
int pad0, pad1; /* Used for 8-byte alignment */
}; };
unsigned long lance_probe1(short ioaddr, unsigned long mem_start); /* A mapping from the chip ID number to the part number and features. */
static struct lance_chip_type {
int id_number;
char *name;
int flags;
} chip_table[] = {
{0x0000, "LANCE 7990", 0}, /* Ancient lance chip. */
{0x0003, "PCnet/ISA 79C960", 0}, /* 79C960 PCnet/ISA. */
{0x2260, "PCnet/ISA+ 79C961", 0}, /* 79C961 PCnet/ISA+ for Plug-n-Play. */
{0x2420, "PCnet/PCI 79C970", 0}, /* 79C970 or 79C974 PCnet-SCSI for PCI */
{0x2430, "PCnet/VLB 79C965", 0}, /* 79C965 PCnet for VL bus. */
{0x0, "PCnet (unknown)", 0},
};
enum {OLD_LANCE = 0, PCNET_ISA=1, PCNET_ISAP=2, PCNET_PCI=3, PCNET_VLB=4, LANCE_UNKNOWN=5};
static int lance_open(struct device *dev); static int lance_open(struct device *dev);
static void lance_init_ring(struct device *dev); static void lance_init_ring(struct device *dev);
static int lance_start_xmit(struct sk_buff *skb, struct device *dev); static int lance_start_xmit(struct sk_buff *skb, struct device *dev);
...@@ -214,631 +235,718 @@ static void set_multicast_list(struct device *dev, int num_addrs, void *addrs); ...@@ -214,631 +235,718 @@ static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
/* This lance probe is unlike the other board probes in 1.0.*. The LANCE may
have to allocate a contiguous low-memory region for bounce buffers.
This requirement is satified by having the lance initialization occur before the
memory management system is started, and thus well before the other probes. */
unsigned long lance_init(unsigned long mem_start, unsigned long mem_end) unsigned long lance_init(unsigned long mem_start, unsigned long mem_end)
{ {
int *port, ports[] = {0x300, 0x320, 0x340, 0x360, 0}; int *port;
for (port = &ports[0]; *port; port++) { for (port = lance_portlist; *port; port++) {
int ioaddr = *port; int ioaddr = *port;
if ( check_region(ioaddr, LANCE_TOTAL_SIZE) == 0 if ( check_region(ioaddr, LANCE_TOTAL_SIZE) == 0
&& inb(ioaddr + 14) == 0x57 && inb(ioaddr + 14) == 0x57
&& inb(ioaddr + 15) == 0x57) { && inb(ioaddr + 15) == 0x57) {
mem_start = lance_probe1(ioaddr, mem_start); mem_start = lance_probe1(ioaddr, mem_start);
}
} }
}
return mem_start; return mem_start;
} }
unsigned long lance_probe1(short ioaddr, unsigned long mem_start) unsigned long lance_probe1(short ioaddr, unsigned long mem_start)
{ {
struct device *dev; struct device *dev;
struct lance_private *lp; struct lance_private *lp;
int hpJ2405A = 0; int i, reset_val, lance_version;
int i, reset_val; /* Flags for specific chips or boards. */
unsigned char hpJ2405A = 0; /* HP ISA adaptor */
int hp_builtin = 0; /* HP on-board ethernet. */
static int did_version = 0; /* Already printed version info. */
/* First we look for special cases.
Check for HP's on-board ethernet by looking for 'HP' in the BIOS.
This method provided by Laurent Julliard, Laurent_Julliard@grenoble.hp.com.
*/
if ( *((unsigned short *) 0x000f0102) == 0x5048) {
short ioaddr_table[] = { 0x300, 0x320, 0x340, 0x360};
/* There are two HP versions, check the BIOS for the configuration port. */
int hp_port = ( *((unsigned char *) 0x000f00f1) & 1) ? 0x499 : 0x99;
/* We can have boards other than the built-in! Verify this is on-board. */
if ((inb(hp_port) & 0xc0) == 0x80
&& ioaddr_table[inb(hp_port) & 3] == ioaddr)
hp_builtin = hp_port;
}
/* We might misrecognize the HP Vectra on-board here, but we check below. */
hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00
&& inb(ioaddr+2) == 0x09);
hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00 /* Reset the LANCE. */
&& inb(ioaddr+2) == 0x09); reset_val = inw(ioaddr+LANCE_RESET); /* Reset the LANCE */
/* Reset the LANCE. */ /* The Un-Reset needed is only needed for the real NE2100, and will
reset_val = inw(ioaddr+LANCE_RESET); /* Reset the LANCE */ confuse the HP board. */
if (!hpJ2405A)
outw(reset_val, ioaddr+LANCE_RESET);
/* The Un-Reset needed is only needed for the real NE2100, and will outw(0x0000, ioaddr+LANCE_ADDR); /* Switch to window 0 */
confuse the HP board. */ if (inw(ioaddr+LANCE_DATA) != 0x0004)
if (!hpJ2405A) return mem_start;
outw(reset_val, ioaddr+LANCE_RESET);
outw(0x0000, ioaddr+LANCE_ADDR); /* Switch to window 0 */ /* Get the version of the chip. */
if (inw(ioaddr+LANCE_DATA) != 0x0004) outw(88, ioaddr+LANCE_ADDR);
return mem_start; if (inw(ioaddr+LANCE_ADDR) != 88) {
lance_version = 0;
} else { /* Good, it's a newer chip. */
int chip_version = inw(ioaddr+LANCE_DATA);
outw(89, ioaddr+LANCE_ADDR);
chip_version |= inw(ioaddr+LANCE_DATA) << 16;
if (lance_debug > 2)
printk(" LANCE chip version is %#x.\n", chip_version);
if ((chip_version & 0xfff) != 0x003)
return mem_start;
chip_version = (chip_version >> 12) & 0xffff;
for (lance_version = 1; chip_table[lance_version].id_number; lance_version++) {
if (chip_table[lance_version].id_number == chip_version)
break;
}
}
dev = init_etherdev(0, sizeof(struct lance_private) dev = init_etherdev(0, sizeof(struct lance_private)
+ PKT_BUF_SZ*(RX_RING_SIZE + TX_RING_SIZE), + PKT_BUF_SZ*(RX_RING_SIZE + TX_RING_SIZE),
&mem_start); &mem_start);
printk("%s: LANCE at %#3x,", dev->name, ioaddr); printk("%s: %s at %#3x,", dev->name, chip_table[lance_version].name, ioaddr);
/* There is a 16 byte station address PROM at the base address. /* There is a 16 byte station address PROM at the base address.
The first six bytes are the station address. */ The first six bytes are the station address. */
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i)); printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
snarf_region(ioaddr, LANCE_TOTAL_SIZE); snarf_region(ioaddr, LANCE_TOTAL_SIZE);
/* Make certain the data structures used by the LANCE are aligned. */ /* Make certain the data structures used by the LANCE are aligned. */
dev->priv = (void *)(((int)dev->priv + 7) & ~7); dev->priv = (void *)(((int)dev->priv + 7) & ~7);
lp = (struct lance_private *)dev->priv; lp = (struct lance_private *)dev->priv;
lp->rx_buffs = (long)dev->priv + sizeof(struct lance_private); lp->rx_buffs = (long)dev->priv + sizeof(struct lance_private);
lp->tx_bounce_buffs = (char (*)[PKT_BUF_SZ]) lp->tx_bounce_buffs = (char (*)[PKT_BUF_SZ])
(lp->rx_buffs + PKT_BUF_SZ*RX_RING_SIZE); (lp->rx_buffs + PKT_BUF_SZ*RX_RING_SIZE);
#ifndef final_version #ifndef final_version
/* This should never happen. */ /* This should never happen. */
if ((int)(lp->rx_ring) & 0x07) { if ((int)(lp->rx_ring) & 0x07) {
printk(" **ERROR** LANCE Rx and Tx rings not on even boundary.\n"); printk(" **ERROR** LANCE Rx and Tx rings not on even boundary.\n");
return mem_start; return mem_start;
} }
#endif #endif
outw(88, ioaddr+LANCE_ADDR); lp->chip_version = lance_version;
lp->old_lance = (inw(ioaddr+LANCE_DATA) != 0x3003);
#if defined(notdef) lp->init_block.mode = 0x0003; /* Disable Rx and Tx. */
printk(lp->old_lance ? " original LANCE (%04x)" : " PCnet-ISA LANCE (%04x)", for (i = 0; i < 6; i++)
inw(ioaddr+LANCE_DATA)); lp->init_block.phys_addr[i] = dev->dev_addr[i];
#endif lp->init_block.filter[0] = 0x00000000;
lp->init_block.filter[1] = 0x00000000;
lp->init_block.rx_ring = (int)lp->rx_ring | RX_RING_LEN_BITS;
lp->init_block.tx_ring = (int)lp->tx_ring | TX_RING_LEN_BITS;
lp->init_block.mode = 0x0003; /* Disable Rx and Tx. */ outw(0x0001, ioaddr+LANCE_ADDR);
for (i = 0; i < 6; i++) inw(ioaddr+LANCE_ADDR);
lp->init_block.phys_addr[i] = dev->dev_addr[i]; outw((short) (int) &lp->init_block, ioaddr+LANCE_DATA);
lp->init_block.filter[0] = 0x00000000;
lp->init_block.filter[1] = 0x00000000;
lp->init_block.rx_ring = (int)lp->rx_ring | RX_RING_LEN_BITS;
lp->init_block.tx_ring = (int)lp->tx_ring | TX_RING_LEN_BITS;
outw(0x0001, ioaddr+LANCE_ADDR);
outw((short) (int) &lp->init_block, ioaddr+LANCE_DATA);
outw(0x0002, ioaddr+LANCE_ADDR);
outw(((int)&lp->init_block) >> 16, ioaddr+LANCE_DATA);
outw(0x0000, ioaddr+LANCE_ADDR);
if (hpJ2405A) {
char dma_tbl[4] = {3, 5, 6, 7};
char irq_tbl[8] = {3, 4, 5, 9, 10, 11, 12, 15};
short reset_val = inw(ioaddr+LANCE_RESET);
dev->dma = dma_tbl[(reset_val >> 2) & 3];
dev->irq = irq_tbl[(reset_val >> 4) & 7];
printk(" HP J2405A IRQ %d DMA %d.\n", dev->irq, dev->dma);
} else {
/* The DMA channel may be passed in on this parameter. */
if (dev->mem_start & 0x07)
dev->dma = dev->mem_start & 0x07;
else if (dev->dma == 0)
dev->dma = LANCE_DMA;
/* To auto-IRQ we enable the initialization-done and DMA err,
interrupts. For now we will always get a DMA error. */
if (dev->irq < 2) {
autoirq_setup(0);
/* Trigger an initialization just for the interrupt. */
outw(0x0041, ioaddr+LANCE_DATA);
dev->irq = autoirq_report(1);
if (dev->irq)
printk(", probed IRQ %d, fixed at DMA %d.\n",
dev->irq, dev->dma);
else {
printk(", failed to detect IRQ line.\n");
return mem_start;
}
} else
printk(" assigned IRQ %d DMA %d.\n", dev->irq, dev->dma);
}
if (! lp->old_lance) {
/* Turn on auto-select of media (10baseT or BNC) so that the user
can watch the LEDs even if the board isn't opened. */
outw(0x0002, ioaddr+LANCE_ADDR); outw(0x0002, ioaddr+LANCE_ADDR);
outw(0x0002, ioaddr+LANCE_BUS_IF); inw(ioaddr+LANCE_ADDR);
} outw(((int)&lp->init_block) >> 16, ioaddr+LANCE_DATA);
outw(0x0000, ioaddr+LANCE_ADDR);
inw(ioaddr+LANCE_ADDR);
if (hp_builtin) {
char dma_tbl[4] = {3, 5, 6, 0};
char irq_tbl[8] = {3, 4, 5, 9};
unsigned char port_val = inb(hp_builtin);
dev->dma = dma_tbl[(port_val >> 4) & 3];
dev->irq = irq_tbl[(port_val >> 2) & 3];
printk(" HP Vectra IRQ %d DMA %d.\n", dev->irq, dev->dma);
} else if (hpJ2405A) {
char dma_tbl[4] = {3, 5, 6, 7};
char irq_tbl[8] = {3, 4, 5, 9, 10, 11, 12, 15};
short reset_val = inw(ioaddr+LANCE_RESET);
dev->dma = dma_tbl[(reset_val >> 2) & 3];
dev->irq = irq_tbl[(reset_val >> 4) & 7];
printk(" HP J2405A IRQ %d DMA %d.\n", dev->irq, dev->dma);
} else if (lance_version == PCNET_ISAP) { /* The plug-n-play version. */
short bus_info;
outw(8, ioaddr+LANCE_ADDR);
bus_info = inw(ioaddr+LANCE_BUS_IF);
dev->dma = bus_info & 0x07;
dev->irq = (bus_info >> 4) & 0x0F;
} else {
/* The DMA channel may be passed in PARAM1. */
if (dev->mem_start & 0x07)
dev->dma = dev->mem_start & 0x07;
}
if (lance_debug > 0) if (dev->irq >= 2)
printk(version); printk(" assigned IRQ %d", dev->irq);
else {
/* To auto-IRQ we enable the initialization-done and DMA error
interrupts. For ISA boards we get a DMA error, but VLB and PCI
boards will work. */
autoirq_setup(0);
/* Trigger an initialization just for the interrupt. */
outw(0x0041, ioaddr+LANCE_DATA);
dev->irq = autoirq_report(1);
if (dev->irq)
printk(", probed IRQ %d", dev->irq);
else {
printk(", failed to detect IRQ line.\n");
return mem_start;
}
/* The LANCE-specific entries in the device structure. */ /* Check for the initialization done bit, 0x0100, which means
dev->open = &lance_open; that we don't need a DMA channel. */
dev->hard_start_xmit = &lance_start_xmit; if (inw(ioaddr+LANCE_DATA) & 0x0100)
dev->stop = &lance_close; dev->dma = 4;
dev->get_stats = &lance_get_stats; }
dev->set_multicast_list = &set_multicast_list;
return mem_start; if (dev->dma == 4) {
printk(", no DMA needed.\n");
} else if (dev->dma) {
if (request_dma(dev->dma, "lance")) {
printk("DMA %d allocation failed.\n", dev->dma);
return mem_start;
} else
printk(", assigned DMA %d.\n", dev->dma);
} else { /* OK, we have to auto-DMA. */
int dmas[] = {5, 6, 7, 3}, boguscnt;
for (i = 0; i < 4; i++) {
int dma = dmas[i];
outw(0x7f04, ioaddr+LANCE_DATA); /* Clear the memory error bits. */
if (request_dma(dma, "lance"))
continue;
enable_dma(dma);
set_dma_mode(dma, DMA_MODE_CASCADE);
/* Trigger an initialization. */
outw(0x0001, ioaddr+LANCE_DATA);
for (boguscnt = 100; boguscnt > 0; --boguscnt)
if (inw(ioaddr+LANCE_DATA) & 0x0900)
break;
if (inw(ioaddr+LANCE_DATA) & 0x0100) {
dev->dma = dma;
printk(", DMA %d.\n", dev->dma);
break;
} else {
disable_dma(dma);
free_dma(dma);
}
}
if (i == 4) { /* Failure: bail. */
printk("DMA detection failed.\n");
return mem_start;
}
}
if (lp->chip_version != OLD_LANCE) {
/* Turn on auto-select of media (10baseT or BNC) so that the user
can watch the LEDs even if the board isn't opened. */
outw(0x0002, ioaddr+LANCE_ADDR);
outw(0x0002, ioaddr+LANCE_BUS_IF);
}
if (lance_debug > 0 && did_version++ == 0)
printk(version);
/* The LANCE-specific entries in the device structure. */
dev->open = &lance_open;
dev->hard_start_xmit = &lance_start_xmit;
dev->stop = &lance_close;
dev->get_stats = &lance_get_stats;
dev->set_multicast_list = &set_multicast_list;
return mem_start;
} }
static int static int
lance_open(struct device *dev) lance_open(struct device *dev)
{ {
struct lance_private *lp = (struct lance_private *)dev->priv; struct lance_private *lp = (struct lance_private *)dev->priv;
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
int i; int i;
if (request_irq(dev->irq, &lance_interrupt, 0, "lance")) {
return -EAGAIN;
}
if (request_irq(dev->irq, &lance_interrupt, 0, "lance")) { /* We used to allocate DMA here, but that was silly.
return -EAGAIN; DMA lines can't be shared! We now permanently snarf them. */
}
if (request_dma(dev->dma,"lance")) { irq2dev_map[dev->irq] = dev;
free_irq(dev->irq);
return -EAGAIN;
}
irq2dev_map[dev->irq] = dev;
/* Reset the LANCE */ /* Reset the LANCE */
inw(ioaddr+LANCE_RESET); inw(ioaddr+LANCE_RESET);
/* The DMA controller is used as a no-operation slave, "cascade mode". */ /* The DMA controller is used as a no-operation slave, "cascade mode". */
enable_dma(dev->dma); enable_dma(dev->dma);
set_dma_mode(dev->dma, DMA_MODE_CASCADE); set_dma_mode(dev->dma, DMA_MODE_CASCADE);
/* Un-Reset the LANCE, needed only for the NE2100. */ /* Un-Reset the LANCE, needed only for the NE2100. */
if (lp->old_lance) if (lp->chip_version == OLD_LANCE)
outw(0, ioaddr+LANCE_RESET); outw(0, ioaddr+LANCE_RESET);
if (! lp->old_lance) { if (lp->chip_version != OLD_LANCE) {
/* This is 79C960-specific: Turn on auto-select of media (AUI, BNC). */ /* This is 79C960-specific: Turn on auto-select of media (AUI, BNC). */
outw(0x0002, ioaddr+LANCE_ADDR);
outw(0x0002, ioaddr+LANCE_BUS_IF);
}
if (lance_debug > 1)
printk("%s: lance_open() irq %d dma %d tx/rx rings %#x/%#x init %#x.\n",
dev->name, dev->irq, dev->dma, (int) lp->tx_ring, (int) lp->rx_ring,
(int) &lp->init_block);
lance_init_ring(dev);
/* Re-initialize the LANCE, and start it when done. */
outw(0x0001, ioaddr+LANCE_ADDR);
outw((short) (int) &lp->init_block, ioaddr+LANCE_DATA);
outw(0x0002, ioaddr+LANCE_ADDR); outw(0x0002, ioaddr+LANCE_ADDR);
outw(0x0002, ioaddr+LANCE_BUS_IF); outw(((int)&lp->init_block) >> 16, ioaddr+LANCE_DATA);
}
outw(0x0004, ioaddr+LANCE_ADDR);
if (lance_debug > 1) outw(0x0d15, ioaddr+LANCE_DATA);
printk("%s: lance_open() irq %d dma %d tx/rx rings %#x/%#x init %#x.\n",
dev->name, dev->irq, dev->dma, (int) lp->tx_ring, (int) lp->rx_ring, outw(0x0000, ioaddr+LANCE_ADDR);
(int) &lp->init_block); outw(0x0001, ioaddr+LANCE_DATA);
lance_init_ring(dev); dev->tbusy = 0;
/* Re-initialize the LANCE, and start it when done. */ dev->interrupt = 0;
outw(0x0001, ioaddr+LANCE_ADDR); dev->start = 1;
outw((short) (int) &lp->init_block, ioaddr+LANCE_DATA); i = 0;
outw(0x0002, ioaddr+LANCE_ADDR); while (i++ < 100)
outw(((int)&lp->init_block) >> 16, ioaddr+LANCE_DATA); if (inw(ioaddr+LANCE_DATA) & 0x0100)
break;
outw(0x0004, ioaddr+LANCE_ADDR); outw(0x0142, ioaddr+LANCE_DATA);
outw(0x0d15, ioaddr+LANCE_DATA);
if (lance_debug > 2)
outw(0x0000, ioaddr+LANCE_ADDR); printk("%s: LANCE open after %d ticks, init block %#x csr0 %4.4x.\n",
outw(0x0001, ioaddr+LANCE_DATA); dev->name, i, (int) &lp->init_block, inw(ioaddr+LANCE_DATA));
dev->tbusy = 0; return 0; /* Always succeed */
dev->interrupt = 0;
dev->start = 1;
i = 0;
while (i++ < 100)
if (inw(ioaddr+LANCE_DATA) & 0x0100)
break;
outw(0x0142, ioaddr+LANCE_DATA);
if (lance_debug > 2)
printk("%s: LANCE open after %d ticks, init block %#x csr0 %4.4x.\n",
dev->name, i, (int) &lp->init_block, inw(ioaddr+LANCE_DATA));
return 0; /* Always succeed */
} }
/* Initialize the LANCE Rx and Tx rings. */ /* Initialize the LANCE Rx and Tx rings. */
static void static void
lance_init_ring(struct device *dev) lance_init_ring(struct device *dev)
{ {
struct lance_private *lp = (struct lance_private *)dev->priv; struct lance_private *lp = (struct lance_private *)dev->priv;
int i; int i;
lp->lock = 0; lp->lock = 0, lp->tx_full = 0;
lp->cur_rx = lp->cur_tx = 0; lp->cur_rx = lp->cur_tx = 0;
lp->dirty_rx = lp->dirty_tx = 0; lp->dirty_rx = lp->dirty_tx = 0;
for (i = 0; i < RX_RING_SIZE; i++) { for (i = 0; i < RX_RING_SIZE; i++) {
lp->rx_ring[i].base = (lp->rx_buffs + i*PKT_BUF_SZ) | 0x80000000; lp->rx_ring[i].base = (lp->rx_buffs + i*PKT_BUF_SZ) | 0x80000000;
lp->rx_ring[i].buf_length = -PKT_BUF_SZ; lp->rx_ring[i].buf_length = -PKT_BUF_SZ;
} }
/* The Tx buffer address is filled in as needed, but we do need to clear /* The Tx buffer address is filled in as needed, but we do need to clear
the upper ownership bit. */ the upper ownership bit. */
for (i = 0; i < TX_RING_SIZE; i++) { for (i = 0; i < TX_RING_SIZE; i++) {
lp->tx_ring[i].base = 0; lp->tx_ring[i].base = 0;
} }
lp->init_block.mode = 0x0000; lp->init_block.mode = 0x0000;
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
lp->init_block.phys_addr[i] = dev->dev_addr[i]; lp->init_block.phys_addr[i] = dev->dev_addr[i];
lp->init_block.filter[0] = 0x00000000; lp->init_block.filter[0] = 0x00000000;
lp->init_block.filter[1] = 0x00000000; lp->init_block.filter[1] = 0x00000000;
lp->init_block.rx_ring = (int)lp->rx_ring | RX_RING_LEN_BITS; lp->init_block.rx_ring = (int)lp->rx_ring | RX_RING_LEN_BITS;
lp->init_block.tx_ring = (int)lp->tx_ring | TX_RING_LEN_BITS; lp->init_block.tx_ring = (int)lp->tx_ring | TX_RING_LEN_BITS;
} }
static int static int
lance_start_xmit(struct sk_buff *skb, struct device *dev) lance_start_xmit(struct sk_buff *skb, struct device *dev)
{ {
struct lance_private *lp = (struct lance_private *)dev->priv; struct lance_private *lp = (struct lance_private *)dev->priv;
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
int entry; int entry;
/* Transmitter timeout, serious problems. */ /* Transmitter timeout, serious problems. */
if (dev->tbusy) { if (dev->tbusy) {
int tickssofar = jiffies - dev->trans_start; int tickssofar = jiffies - dev->trans_start;
if (tickssofar < 10) if (tickssofar < 10)
return 1; return 1;
outw(0, ioaddr+LANCE_ADDR); outw(0, ioaddr+LANCE_ADDR);
printk("%s: transmit timed out, status %4.4x, resetting.\n", printk("%s: transmit timed out, status %4.4x, resetting.\n",
dev->name, inw(ioaddr+LANCE_DATA)); dev->name, inw(ioaddr+LANCE_DATA));
outw(0x0001, ioaddr+LANCE_DATA); outw(0x0001, ioaddr+LANCE_DATA);
lp->stats.tx_errors++; lp->stats.tx_errors++;
#ifndef final_version #ifndef final_version
{ {
int i; int i;
printk(" Ring data dump: dirty_tx %d cur_tx %d cur_rx %d.", printk(" Ring data dump: dirty_tx %d cur_tx %d cur_rx %d.",
lp->dirty_tx, lp->cur_tx, lp->cur_rx); lp->dirty_tx, lp->cur_tx, lp->cur_rx);
for (i = 0 ; i < RX_RING_SIZE; i++) for (i = 0 ; i < RX_RING_SIZE; i++)
printk("%s %08x %04x %04x", i & 0x3 ? "" : "\n ", printk("%s %08x %04x %04x", i & 0x3 ? "" : "\n ",
lp->rx_ring[i].base, -lp->rx_ring[i].buf_length, lp->rx_ring[i].base, -lp->rx_ring[i].buf_length,
lp->rx_ring[i].msg_length); lp->rx_ring[i].msg_length);
for (i = 0 ; i < TX_RING_SIZE; i++) for (i = 0 ; i < TX_RING_SIZE; i++)
printk(" %s%08x %04x %04x", i & 0x3 ? "" : "\n ", printk(" %s%08x %04x %04x", i & 0x3 ? "" : "\n ",
lp->tx_ring[i].base, -lp->tx_ring[i].length, lp->tx_ring[i].base, -lp->tx_ring[i].length,
lp->tx_ring[i].misc); lp->tx_ring[i].misc);
printk("\n"); printk("\n");
} }
#endif #endif
lance_init_ring(dev); lance_init_ring(dev);
outw(0x0043, ioaddr+LANCE_DATA); outw(0x0043, ioaddr+LANCE_DATA);
dev->tbusy=0; dev->tbusy=0;
dev->trans_start = jiffies; dev->trans_start = jiffies;
return 0; return 0;
} }
if (skb == NULL) {
dev_tint(dev);
return 0;
}
if (skb->len <= 0) if (skb == NULL) {
return 0; dev_tint(dev);
return 0;
}
if (lance_debug > 3) { if (skb->len <= 0)
outw(0x0000, ioaddr+LANCE_ADDR); return 0;
printk("%s: lance_start_xmit() called, csr0 %4.4x.\n", dev->name,
inw(ioaddr+LANCE_DATA));
outw(0x0000, ioaddr+LANCE_DATA);
}
/* Block a timer-based transmit from overlapping. This could better be
done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
if (set_bit(0, (void*)&dev->tbusy) != 0) {
printk("%s: Transmitter access conflict.\n", dev->name);
return 1;
}
if (set_bit(0, (void*)&lp->lock) != 0) {
if (lance_debug > 2)
printk("%s: tx queue lock!.\n", dev->name);
/* don't clear dev->tbusy flag. */
return 1;
}
/* Fill in a Tx ring entry */
/* Mask to ring buffer boundary. */
entry = lp->cur_tx & TX_RING_MOD_MASK;
/* Caution: the write order is important here, set the base address
with the "ownership" bits last. */
/* The old LANCE chips doesn't automatically pad buffers to min. size. */
if (lp->old_lance) {
lp->tx_ring[entry].length =
-(ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN);
} else
lp->tx_ring[entry].length = -skb->len;
lp->tx_ring[entry].misc = 0x0000;
/* If any part of this buffer is >16M we must copy it to a low-memory
buffer. */
if ((int)(skb->data) + skb->len > 0x01000000) {
if (lance_debug > 5)
printk("%s: bouncing a high-memory packet (%#x).\n",
dev->name, (int)(skb->data));
memcpy(&lp->tx_bounce_buffs[entry], skb->data, skb->len);
lp->tx_ring[entry].base =
(int)(lp->tx_bounce_buffs + entry) | 0x83000000;
dev_kfree_skb (skb, FREE_WRITE);
} else {
lp->tx_ring[entry].base = (int)(skb->data) | 0x83000000;
}
lp->cur_tx++;
/* Trigger an immediate send poll. */
outw(0x0000, ioaddr+LANCE_ADDR);
outw(0x0048, ioaddr+LANCE_DATA);
dev->trans_start = jiffies;
cli();
lp->lock = 0;
if (lp->tx_ring[(entry+1) & TX_RING_MOD_MASK].base == 0)
dev->tbusy=0;
sti();
return 0;
}
/* The LANCE interrupt handler. */ if (lance_debug > 3) {
static void outw(0x0000, ioaddr+LANCE_ADDR);
lance_interrupt(int reg_ptr) printk("%s: lance_start_xmit() called, csr0 %4.4x.\n", dev->name,
{ inw(ioaddr+LANCE_DATA));
int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2); outw(0x0000, ioaddr+LANCE_DATA);
struct device *dev = (struct device *)(irq2dev_map[irq]); }
struct lance_private *lp;
int csr0, ioaddr;
if (dev == NULL) { /* Block a timer-based transmit from overlapping. This could better be
printk ("lance_interrupt(): irq %d for unknown device.\n", irq); done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
return; if (set_bit(0, (void*)&dev->tbusy) != 0) {
} printk("%s: Transmitter access conflict.\n", dev->name);
return 1;
}
ioaddr = dev->base_addr; if (set_bit(0, (void*)&lp->lock) != 0) {
lp = (struct lance_private *)dev->priv; if (lance_debug > 2)
if (dev->interrupt) printk("%s: tx queue lock!.\n", dev->name);
printk("%s: Re-entering the interrupt handler.\n", dev->name); /* don't clear dev->tbusy flag. */
return 1;
}
dev->interrupt = 1; /* Fill in a Tx ring entry */
outw(0x00, dev->base_addr + LANCE_ADDR); /* Mask to ring buffer boundary. */
csr0 = inw(dev->base_addr + LANCE_DATA); entry = lp->cur_tx & TX_RING_MOD_MASK;
/* Acknowledge all of the current interrupt sources ASAP. */ /* Caution: the write order is important here, set the base address
outw(csr0 & ~0x004f, dev->base_addr + LANCE_DATA); with the "ownership" bits last. */
if (lance_debug > 5) /* The old LANCE chips doesn't automatically pad buffers to min. size. */
printk("%s: interrupt csr0=%#2.2x new csr=%#2.2x.\n", if (lp->chip_version == OLD_LANCE) {
dev->name, csr0, inw(dev->base_addr + LANCE_DATA)); lp->tx_ring[entry].length =
-(ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN);
} else
lp->tx_ring[entry].length = -skb->len;
lp->tx_ring[entry].misc = 0x0000;
/* If any part of this buffer is >16M we must copy it to a low-memory
buffer. */
if ((int)(skb->data) + skb->len > 0x01000000) {
if (lance_debug > 5)
printk("%s: bouncing a high-memory packet (%#x).\n",
dev->name, (int)(skb->data));
memcpy(&lp->tx_bounce_buffs[entry], skb->data, skb->len);
lp->tx_ring[entry].base =
(int)(lp->tx_bounce_buffs + entry) | 0x83000000;
dev_kfree_skb (skb, FREE_WRITE);
} else {
lp->tx_skbuff[entry] = skb;
lp->tx_ring[entry].base = (int)(skb->data) | 0x83000000;
}
lp->cur_tx++;
if (csr0 & 0x0400) /* Rx interrupt */ /* Trigger an immediate send poll. */
lance_rx(dev); outw(0x0000, ioaddr+LANCE_ADDR);
outw(0x0048, ioaddr+LANCE_DATA);
if (csr0 & 0x0200) { /* Tx-done interrupt */ dev->trans_start = jiffies;
int dirty_tx = lp->dirty_tx;
while (dirty_tx < lp->cur_tx) { cli();
int entry = dirty_tx & TX_RING_MOD_MASK; lp->lock = 0;
int status = lp->tx_ring[entry].base; if (lp->tx_ring[(entry+1) & TX_RING_MOD_MASK].base == 0)
void *databuff; dev->tbusy=0;
else
if (status < 0) lp->tx_full = 1;
break; /* It still hasn't been Txed */ sti();
lp->tx_ring[entry].base = 0; return 0;
databuff = (void*)(status & 0x00ffffff); }
if (status & 0x40000000) { /* There was an major error, log it. */ /* The LANCE interrupt handler. */
int err_status = lp->tx_ring[entry].misc; static void
lp->stats.tx_errors++; lance_interrupt(int reg_ptr)
if (err_status & 0x0400) lp->stats.tx_aborted_errors++; {
if (err_status & 0x0800) lp->stats.tx_carrier_errors++; int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
if (err_status & 0x1000) lp->stats.tx_window_errors++; struct device *dev = (struct device *)(irq2dev_map[irq]);
if (err_status & 0x4000) lp->stats.tx_fifo_errors++; struct lance_private *lp;
/* Perhaps we should re-init() after the FIFO error. */ int csr0, ioaddr;
} else {
if (status & 0x18000000) if (dev == NULL) {
lp->stats.collisions++; printk ("lance_interrupt(): irq %d for unknown device.\n", irq);
lp->stats.tx_packets++; return;
}
/* We don't free the skb if it's a data-only copy in the bounce
buffer. The address checks here are sorted -- the first test
should always work. */
if (databuff >= (void*)(&lp->tx_bounce_buffs[TX_RING_SIZE])
|| databuff < (void*)(lp->tx_bounce_buffs)) {
struct sk_buff *skb = ((struct sk_buff *)databuff) - 1;
dev_kfree_skb(skb,FREE_WRITE);
/* Warning: skb may well vanish at the point you call
device_release! */
}
dirty_tx++;
} }
ioaddr = dev->base_addr;
lp = (struct lance_private *)dev->priv;
if (dev->interrupt)
printk("%s: Re-entering the interrupt handler.\n", dev->name);
dev->interrupt = 1;
outw(0x00, dev->base_addr + LANCE_ADDR);
csr0 = inw(dev->base_addr + LANCE_DATA);
/* Acknowledge all of the current interrupt sources ASAP. */
outw(csr0 & ~0x004f, dev->base_addr + LANCE_DATA);
if (lance_debug > 5)
printk("%s: interrupt csr0=%#2.2x new csr=%#2.2x.\n",
dev->name, csr0, inw(dev->base_addr + LANCE_DATA));
if (csr0 & 0x0400) /* Rx interrupt */
lance_rx(dev);
if (csr0 & 0x0200) { /* Tx-done interrupt */
int dirty_tx = lp->dirty_tx;
while (dirty_tx < lp->cur_tx) {
int entry = dirty_tx & TX_RING_MOD_MASK;
int status = lp->tx_ring[entry].base;
if (status < 0)
break; /* It still hasn't been Txed */
lp->tx_ring[entry].base = 0;
if (status & 0x40000000) { /* There was an major error, log it. */
int err_status = lp->tx_ring[entry].misc;
lp->stats.tx_errors++;
if (err_status & 0x0400) lp->stats.tx_aborted_errors++;
if (err_status & 0x0800) lp->stats.tx_carrier_errors++;
if (err_status & 0x1000) lp->stats.tx_window_errors++;
if (err_status & 0x4000) lp->stats.tx_fifo_errors++;
/* Perhaps we should re-init() after the FIFO error. */
} else {
if (status & 0x18000000)
lp->stats.collisions++;
lp->stats.tx_packets++;
}
/* We must free the original skb if it's not a data-only copy
in the bounce buffer. */
if (lp->tx_skbuff[entry]) {
dev_kfree_skb(lp->tx_skbuff[entry],FREE_WRITE);
lp->tx_skbuff[entry] = 0;
}
dirty_tx++;
}
#ifndef final_version #ifndef final_version
if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) { if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) {
printk("out-of-sync dirty pointer, %d vs. %d.\n", printk("out-of-sync dirty pointer, %d vs. %d.\n",
dirty_tx, lp->cur_tx); dirty_tx, lp->cur_tx);
dirty_tx += TX_RING_SIZE; dirty_tx += TX_RING_SIZE;
} }
#endif #endif
if (dev->tbusy && dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) { if (lp->tx_full && dev->tbusy && dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
/* The ring is no longer full, clear tbusy. */ /* The ring is no longer full, clear tbusy. */
dev->tbusy = 0; lp->tx_full = 0;
mark_bh(NET_BH); dev->tbusy = 0;
} mark_bh(NET_BH);
}
lp->dirty_tx = dirty_tx; lp->dirty_tx = dirty_tx;
} }
if (csr0 & 0x8000) { if (csr0 & 0x8000) { /* Check the error summary bit. */
if (csr0 & 0x4000) lp->stats.tx_errors++; if (csr0 & 0x4000) lp->stats.tx_errors++; /* Tx babble. */
if (csr0 & 0x1000) lp->stats.rx_errors++; if (csr0 & 0x1000) lp->stats.rx_errors++; /* Missed a Rx frame. */
} }
/* Clear the interrupts we've handled. */ /* Clear any other interrupt. */
outw(0x0000, dev->base_addr + LANCE_ADDR); outw(0x0000, dev->base_addr + LANCE_ADDR);
outw(0x7f40, dev->base_addr + LANCE_DATA); outw(0x7f40, dev->base_addr + LANCE_DATA);
if (lance_debug > 4) if (lance_debug > 4)
printk("%s: exiting interrupt, csr%d=%#4.4x.\n", printk("%s: exiting interrupt, csr%d=%#4.4x.\n",
dev->name, inw(ioaddr + LANCE_ADDR), dev->name, inw(ioaddr + LANCE_ADDR),
inw(dev->base_addr + LANCE_DATA)); inw(dev->base_addr + LANCE_DATA));
dev->interrupt = 0; dev->interrupt = 0;
return; return;
} }
static int static int
lance_rx(struct device *dev) lance_rx(struct device *dev)
{ {
struct lance_private *lp = (struct lance_private *)dev->priv; struct lance_private *lp = (struct lance_private *)dev->priv;
int entry = lp->cur_rx & RX_RING_MOD_MASK; int entry = lp->cur_rx & RX_RING_MOD_MASK;
int i; int i;
/* If we own the next entry, it's a new packet. Send it up. */ /* If we own the next entry, it's a new packet. Send it up. */
while (lp->rx_ring[entry].base >= 0) { while (lp->rx_ring[entry].base >= 0) {
int status = lp->rx_ring[entry].base >> 24; int status = lp->rx_ring[entry].base >> 24;
if (status != 0x03) { /* There was an error. */ if (status != 0x03) { /* There was an error. */
/* There is an tricky error noted by John Murphy, /* There is an tricky error noted by John Murphy,
<murf@perftech.com> to Russ Nelson: Even with full-sized <murf@perftech.com> to Russ Nelson: Even with full-sized
buffers it's possible for a jabber packet to use two buffers it's possible for a jabber packet to use two
buffers, with only the last correctly noting the error. */ buffers, with only the last correctly noting the error. */
if (status & 0x01) /* Only count a general error at the */ if (status & 0x01) /* Only count a general error at the */
lp->stats.rx_errors++; /* end of a packet.*/ lp->stats.rx_errors++; /* end of a packet.*/
if (status & 0x20) lp->stats.rx_frame_errors++; if (status & 0x20) lp->stats.rx_frame_errors++;
if (status & 0x10) lp->stats.rx_over_errors++; if (status & 0x10) lp->stats.rx_over_errors++;
if (status & 0x08) lp->stats.rx_crc_errors++; if (status & 0x08) lp->stats.rx_crc_errors++;
if (status & 0x04) lp->stats.rx_fifo_errors++; if (status & 0x04) lp->stats.rx_fifo_errors++;
lp->rx_ring[entry].base &= 0x03ffffff; lp->rx_ring[entry].base &= 0x03ffffff;
} else { } else {
/* Malloc up new buffer, compatible with net-2e. */ /* Malloc up new buffer, compatible with net-2e. */
short pkt_len = lp->rx_ring[entry].msg_length; short pkt_len = lp->rx_ring[entry].msg_length;
struct sk_buff *skb; struct sk_buff *skb;
skb = alloc_skb(pkt_len, GFP_ATOMIC); skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) { if (skb == NULL) {
printk("%s: Memory squeeze, deferring packet.\n", dev->name); printk("%s: Memory squeeze, deferring packet.\n", dev->name);
for (i=0; i < RX_RING_SIZE; i++) for (i=0; i < RX_RING_SIZE; i++)
if (lp->rx_ring[(entry+i) & RX_RING_MOD_MASK].base < 0) if (lp->rx_ring[(entry+i) & RX_RING_MOD_MASK].base < 0)
break; break;
if (i > RX_RING_SIZE -2) { if (i > RX_RING_SIZE -2) {
lp->stats.rx_dropped++; lp->stats.rx_dropped++;
lp->rx_ring[entry].base |= 0x80000000; lp->rx_ring[entry].base |= 0x80000000;
lp->cur_rx++; lp->cur_rx++;
}
break;
}
skb->len = pkt_len;
skb->dev = dev;
memcpy(skb->data,
(unsigned char *)(lp->rx_ring[entry].base & 0x00ffffff),
pkt_len);
netif_rx(skb);
lp->stats.rx_packets++;
} }
break;
}
skb->len = pkt_len;
skb->dev = dev;
memcpy(skb->data,
(unsigned char *)(lp->rx_ring[entry].base & 0x00ffffff),
pkt_len);
netif_rx(skb);
lp->stats.rx_packets++;
}
lp->rx_ring[entry].base |= 0x80000000; lp->rx_ring[entry].base |= 0x80000000;
entry = (++lp->cur_rx) & RX_RING_MOD_MASK; /* The docs say that the buffer length isn't touched, but Andrew Boyd
} of QNX reports that some revs of the 79C965 clear it. */
lp->rx_ring[entry].buf_length = -PKT_BUF_SZ;
entry = (++lp->cur_rx) & RX_RING_MOD_MASK;
}
/* We should check that at least two ring entries are free. If not, /* We should check that at least two ring entries are free. If not,
we should free one and mark stats->rx_dropped++. */ we should free one and mark stats->rx_dropped++. */
return 0; return 0;
} }
static int static int
lance_close(struct device *dev) lance_close(struct device *dev)
{ {
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
struct lance_private *lp = (struct lance_private *)dev->priv; struct lance_private *lp = (struct lance_private *)dev->priv;
dev->start = 0; dev->start = 0;
dev->tbusy = 1; dev->tbusy = 1;
outw(112, ioaddr+LANCE_ADDR); outw(112, ioaddr+LANCE_ADDR);
lp->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA); lp->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA);
outw(0, ioaddr+LANCE_ADDR); outw(0, ioaddr+LANCE_ADDR);
if (lance_debug > 1) if (lance_debug > 1)
printk("%s: Shutting down ethercard, status was %2.2x.\n", printk("%s: Shutting down ethercard, status was %2.2x.\n",
dev->name, inw(ioaddr+LANCE_DATA)); dev->name, inw(ioaddr+LANCE_DATA));
/* We stop the LANCE here -- it occasionally polls /* We stop the LANCE here -- it occasionally polls
memory if we don't. */ memory if we don't. */
outw(0x0004, ioaddr+LANCE_DATA); outw(0x0004, ioaddr+LANCE_DATA);
disable_dma(dev->dma); disable_dma(dev->dma);
free_irq(dev->irq); free_irq(dev->irq);
free_dma(dev->dma);
irq2dev_map[dev->irq] = 0; irq2dev_map[dev->irq] = 0;
return 0; return 0;
} }
static struct enet_statistics * static struct enet_statistics *
lance_get_stats(struct device *dev) lance_get_stats(struct device *dev)
{ {
struct lance_private *lp = (struct lance_private *)dev->priv; struct lance_private *lp = (struct lance_private *)dev->priv;
short ioaddr = dev->base_addr; short ioaddr = dev->base_addr;
short saved_addr; short saved_addr;
cli(); cli();
saved_addr = inw(ioaddr+LANCE_ADDR); saved_addr = inw(ioaddr+LANCE_ADDR);
outw(112, ioaddr+LANCE_ADDR); outw(112, ioaddr+LANCE_ADDR);
lp->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA); lp->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA);
outw(saved_addr, ioaddr+LANCE_ADDR); outw(saved_addr, ioaddr+LANCE_ADDR);
sti(); sti();
return &lp->stats; return &lp->stats;
} }
/* Set or clear the multicast filter for this adaptor. /* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list num_addrs == 0 Normal mode, clear multicast list
num_addrs > 0 Multicast mode, receive normal and MC packets, and do num_addrs > 0 Multicast mode, receive normal and MC packets, and do
best-effort filtering. best-effort filtering.
*/ */
static void static void
set_multicast_list(struct device *dev, int num_addrs, void *addrs) set_multicast_list(struct device *dev, int num_addrs, void *addrs)
{ {
short ioaddr = dev->base_addr; short ioaddr = dev->base_addr;
/* We take the simple way out and always enable promiscuous mode. */
outw(0, ioaddr+LANCE_ADDR);
outw(0x0004, ioaddr+LANCE_DATA); /* Temporarily stop the lance. */
outw(15, ioaddr+LANCE_ADDR); /* We take the simple way out and always enable promiscuous mode. */
if (num_addrs >= 0) { outw(0, ioaddr+LANCE_ADDR);
short multicast_table[4]; outw(0x0004, ioaddr+LANCE_DATA); /* Temporarily stop the lance. */
int i;
/* We don't use the multicast table, but rely on upper-layer filtering. */ outw(15, ioaddr+LANCE_ADDR);
memset(multicast_table, (num_addrs == 0) ? 0 : -1, sizeof(multicast_table)); if (num_addrs >= 0) {
for (i = 0; i < 4; i++) { short multicast_table[4];
outw(8 + i, ioaddr+LANCE_ADDR); int i;
outw(multicast_table[i], ioaddr+LANCE_DATA); /* We don't use the multicast table, but rely on upper-layer filtering. */
memset(multicast_table, (num_addrs == 0) ? 0 : -1, sizeof(multicast_table));
for (i = 0; i < 4; i++) {
outw(8 + i, ioaddr+LANCE_ADDR);
outw(multicast_table[i], ioaddr+LANCE_DATA);
}
outw(0x0000, ioaddr+LANCE_DATA); /* Unset promiscuous mode */
} else {
outw(0x8000, ioaddr+LANCE_DATA); /* Set promiscuous mode */
} }
outw(0x0000, ioaddr+LANCE_DATA); /* Unset promiscuous mode */
} else {
outw(0x8000, ioaddr+LANCE_DATA); /* Set promiscuous mode */
}
outw(0, ioaddr+LANCE_ADDR); outw(0, ioaddr+LANCE_ADDR);
outw(0x0142, ioaddr+LANCE_DATA); /* Resume normal operation. */ outw(0x0142, ioaddr+LANCE_DATA); /* Resume normal operation. */
} }
#ifdef HAVE_DEVLIST
static unsigned int lance_portlist[] = {0x300, 0x320, 0x340, 0x360, 0};
struct netdev_entry lance_drv =
{"lance", lance_probe1, LANCE_TOTAL_SIZE, lance_portlist};
#endif
/* /*
* Local variables: * Local variables:
* compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c lance.c" * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c lance.c"
* c-indent-level: 4
* tab-width: 4
* End: * End:
*/ */
...@@ -311,6 +311,7 @@ static void *addresses[] = ...@@ -311,6 +311,7 @@ static void *addresses[] =
(void *) 0xd8000, (void *) 0xd8000,
(void *) 0xe0000, (void *) 0xe0000,
(void *) 0xf0000, (void *) 0xf0000,
(void *) 0xeb800, /* VTech Platinum SMP */
}; };
#define ADDRESS_COUNT (sizeof( addresses ) / sizeof( unsigned )) #define ADDRESS_COUNT (sizeof( addresses ) / sizeof( unsigned ))
......
...@@ -156,6 +156,7 @@ static struct blist blacklist[] = ...@@ -156,6 +156,7 @@ static struct blist blacklist[] =
{"TEXEL","CD-ROM","1.06"}, /* causes failed REQUEST SENSE on lun 1 for seagate {"TEXEL","CD-ROM","1.06"}, /* causes failed REQUEST SENSE on lun 1 for seagate
* controller, which causes SCSI code to reset bus.*/ * controller, which causes SCSI code to reset bus.*/
{"QUANTUM","LPS525S","3110"},/* Locks sometimes if polled for lun != 0 */ {"QUANTUM","LPS525S","3110"},/* Locks sometimes if polled for lun != 0 */
{"QUANTUM","PD1225S","3110"},/* Locks sometimes if polled for lun != 0 */
{NULL, NULL, NULL}}; {NULL, NULL, NULL}};
static int blacklisted(unsigned char * response_data){ static int blacklisted(unsigned char * response_data){
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source. * Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source.
* Ross Biro, <bir7@leland.Stanford.Edu> * Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Florian La Roche.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -59,5 +60,28 @@ struct arpreq { ...@@ -59,5 +60,28 @@ struct arpreq {
#define ATF_PUBL 0x08 /* publish entry */ #define ATF_PUBL 0x08 /* publish entry */
#define ATF_USETRAILERS 0x10 /* has requested trailers */ #define ATF_USETRAILERS 0x10 /* has requested trailers */
/*
* This structure defines an ethernet arp header.
*/
struct arphdr
{
unsigned short ar_hrd; /* format of hardware address */
unsigned short ar_pro; /* format of protocol address */
unsigned char ar_hln; /* length of hardware address */
unsigned char ar_pln; /* length of protocol address */
unsigned short ar_op; /* ARP opcode (command) */
#if 0
/*
* Ethernet looks like this : This bit is variable sized however...
*/
unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
unsigned char ar_sip[4]; /* sender IP address */
unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
unsigned char ar_tip[4]; /* target IP address */
#endif
};
#endif /* _LINUX_IF_ARP_H */ #endif /* _LINUX_IF_ARP_H */
...@@ -245,6 +245,8 @@ void unmap_fixup(struct vm_area_struct *area, ...@@ -245,6 +245,8 @@ void unmap_fixup(struct vm_area_struct *area,
/* Add end mapping -- leave beginning for below */ /* Add end mapping -- leave beginning for below */
mpnt = (struct vm_area_struct *)kmalloc(sizeof(*mpnt), GFP_KERNEL); mpnt = (struct vm_area_struct *)kmalloc(sizeof(*mpnt), GFP_KERNEL);
if (!mpnt)
return;
*mpnt = *area; *mpnt = *area;
mpnt->vm_offset += (end - area->vm_start); mpnt->vm_offset += (end - area->vm_start);
mpnt->vm_start = end; mpnt->vm_start = end;
...@@ -256,6 +258,8 @@ void unmap_fixup(struct vm_area_struct *area, ...@@ -256,6 +258,8 @@ void unmap_fixup(struct vm_area_struct *area,
/* construct whatever mapping is needed */ /* construct whatever mapping is needed */
mpnt = (struct vm_area_struct *)kmalloc(sizeof(*mpnt), GFP_KERNEL); mpnt = (struct vm_area_struct *)kmalloc(sizeof(*mpnt), GFP_KERNEL);
if (!mpnt)
return;
*mpnt = *area; *mpnt = *area;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
} }
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
* Alan Cox : Drop data when a device is downed. * Alan Cox : Drop data when a device is downed.
* Alan Cox : Use init_timer(). * Alan Cox : Use init_timer().
* Alan Cox : Double lock fixes. * Alan Cox : Double lock fixes.
* Martin Seine : Move the arphdr structure
* to if_arp.h for compatibility
* with BSD based programs.
*/ */
#include <linux/types.h> #include <linux/types.h>
...@@ -86,29 +89,6 @@ struct arp_table ...@@ -86,29 +89,6 @@ struct arp_table
struct sk_buff_head skb; /* list of queued packets */ struct sk_buff_head skb; /* list of queued packets */
}; };
/*
* This structure defines an ethernet arp header.
*/
struct arphdr
{
unsigned short ar_hrd; /* format of hardware address */
unsigned short ar_pro; /* format of protocol address */
unsigned char ar_hln; /* length of hardware address */
unsigned char ar_pln; /* length of protocol address */
unsigned short ar_op; /* ARP opcode (command) */
#if 0
/*
* Ethernet looks like this : This bit is variable sized however...
*/
unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
unsigned char ar_sip[4]; /* sender IP address */
unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
unsigned char ar_tip[4]; /* target IP address */
#endif
};
/* /*
* Configurable Parameters (don't touch unless you know what you are doing * Configurable Parameters (don't touch unless you know what you are doing
......
...@@ -87,10 +87,10 @@ register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct ...@@ -87,10 +87,10 @@ register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct
proto->rcvfunc = rcvfunc; proto->rcvfunc = rcvfunc;
proto->header_length = 3; proto->header_length = 3;
proto->datalink_header = p8022_datalink_header; proto->datalink_header = p8022_datalink_header;
}
proto->next = p8022_list; proto->next = p8022_list;
p8022_list = proto; p8022_list = proto;
}
return proto; return proto;
} }
......
...@@ -80,14 +80,12 @@ ...@@ -80,14 +80,12 @@
* Alan Cox : Window clamping * Alan Cox : Window clamping
* Michael Riepe : Bug in tcp_check() * Michael Riepe : Bug in tcp_check()
* Matt Dillon : More TCP improvements and RST bug fixes * Matt Dillon : More TCP improvements and RST bug fixes
* Matt Dillon : Yet more small nasties remove from the TCP code
* (Be very nice to this man if tcp finally works 100%) 8)
* Alan Cox : BSD accept sematics.
* *
* *
* To Fix: * To Fix:
* Possibly a problem with accept(). BSD accept never fails after
* it causes a select. Linux can - given the official select semantics I
* feel that _really_ its the BSD network programs that are bust (notably
* inetd, which hangs occasionally because of this).
*
* Fast path the code. Two things here - fix the window calculation * Fast path the code. Two things here - fix the window calculation
* so it doesn't iterate over the queue, also spot packets with no funny * so it doesn't iterate over the queue, also spot packets with no funny
* options arriving in order and process directly. * options arriving in order and process directly.
...@@ -224,6 +222,40 @@ int tcp_select_window(struct sock *sk) ...@@ -224,6 +222,40 @@ int tcp_select_window(struct sock *sk)
return(new_window); return(new_window);
} }
/*
* Find someone to 'accept'. Must be called with
* sk->inuse=1 or cli()
*/
static struct sk_buff *tcp_find_established(struct sock *s)
{
struct sk_buff *p=skb_peek(&s->receive_queue);
if(p==NULL)
return NULL;
do
{
if(p->sk->state>=TCP_ESTABLISHED)
return p;
p=p->next;
}
while(p!=skb_peek(&s->receive_queue));
return NULL;
}
static struct sk_buff *tcp_dequeue_established(struct sock *s)
{
struct sk_buff *skb;
unsigned long flags;
save_flags(flags);
cli();
skb=tcp_find_established(s);
if(skb!=NULL)
skb_unlink(skb); /* Take it off the queue */
restore_flags(flags);
return skb;
}
/* /*
* Enter the time wait state. * Enter the time wait state.
*/ */
...@@ -406,7 +438,7 @@ static int tcp_select(struct sock *sk, int sel_type, select_table *wait) ...@@ -406,7 +438,7 @@ static int tcp_select(struct sock *sk, int sel_type, select_table *wait)
printk("-select out"); printk("-select out");
if (skb_peek(&sk->receive_queue) != NULL) if (skb_peek(&sk->receive_queue) != NULL)
{ {
if (sk->state == TCP_LISTEN || tcp_readable(sk)) if ((sk->state == TCP_LISTEN && tcp_find_established(sk)) || tcp_readable(sk))
{ {
release_sock(sk); release_sock(sk);
if(sk->debug) if(sk->debug)
...@@ -445,12 +477,11 @@ static int tcp_select(struct sock *sk, int sel_type, select_table *wait) ...@@ -445,12 +477,11 @@ static int tcp_select(struct sock *sk, int sel_type, select_table *wait)
} }
/* /*
* FIXME: * This is now right thanks to a small fix
* Hack so it will probably be able to write * by Matt Dillon.
* something if it says it's ok to write.
*/ */
if (sk->prot->wspace(sk) >= sk->mss) if (sk->prot->wspace(sk) >= sk->mtu+128+sk->prot->max_header)
{ {
release_sock(sk); release_sock(sk);
/* This should cause connect to work ok. */ /* This should cause connect to work ok. */
...@@ -2523,15 +2554,7 @@ static int tcp_ack(struct sock *sk, struct tcphdr *th, unsigned long saddr, int ...@@ -2523,15 +2554,7 @@ static int tcp_ack(struct sock *sk, struct tcphdr *th, unsigned long saddr, int
if (sk->retransmits && sk->timeout == TIME_KEEPOPEN) if (sk->retransmits && sk->timeout == TIME_KEEPOPEN)
sk->retransmits = 0; sk->retransmits = 0;
#if 0
/*
* Not quite clear why the +1 and -1 here, and why not +1 in next line
*/
if (after(ack, sk->sent_seq+1) || before(ack, sk->rcv_ack_seq-1))
#else
if (after(ack, sk->sent_seq) || before(ack, sk->rcv_ack_seq)) if (after(ack, sk->sent_seq) || before(ack, sk->rcv_ack_seq))
#endif
{ {
if(sk->debug) if(sk->debug)
printk("Ack ignored %lu %lu\n",ack,sk->sent_seq); printk("Ack ignored %lu %lu\n",ack,sk->sent_seq);
...@@ -2941,7 +2964,8 @@ static int tcp_ack(struct sock *sk, struct tcphdr *th, unsigned long saddr, int ...@@ -2941,7 +2964,8 @@ static int tcp_ack(struct sock *sk, struct tcphdr *th, unsigned long saddr, int
/* /*
* Incoming ACK to a FIN we sent in the case of our initiating the close. * Incoming ACK to a FIN we sent in the case of our initiating the close.
* *
* Move to FIN_WAIT2 to await a FIN from the other end. * Move to FIN_WAIT2 to await a FIN from the other end. Set
* SEND_SHUTDOWN but not RCV_SHUTDOWN as data can still be coming in.
*/ */
if (sk->state == TCP_FIN_WAIT1) if (sk->state == TCP_FIN_WAIT1)
...@@ -2952,13 +2976,15 @@ static int tcp_ack(struct sock *sk, struct tcphdr *th, unsigned long saddr, int ...@@ -2952,13 +2976,15 @@ static int tcp_ack(struct sock *sk, struct tcphdr *th, unsigned long saddr, int
if (sk->rcv_ack_seq == sk->write_seq) if (sk->rcv_ack_seq == sk->write_seq)
{ {
flag |= 1; flag |= 1;
#ifdef THIS_BIT_IS_WRONG
if (sk->acked_seq != sk->fin_seq) if (sk->acked_seq != sk->fin_seq)
{ {
tcp_time_wait(sk); tcp_time_wait(sk);
} }
else else
#endif
{ {
sk->shutdown = SHUTDOWN_MASK; sk->shutdown |= SEND_SHUTDOWN;
tcp_set_state(sk,TCP_FIN_WAIT2); tcp_set_state(sk,TCP_FIN_WAIT2);
} }
} }
...@@ -3065,7 +3091,7 @@ static int tcp_data(struct sk_buff *skb, struct sock *sk, ...@@ -3065,7 +3091,7 @@ static int tcp_data(struct sk_buff *skb, struct sock *sk,
{ {
new_seq= th->seq + skb->len + th->syn; /* Right edge of _data_ part of frame */ new_seq= th->seq + skb->len + th->syn; /* Right edge of _data_ part of frame */
if(after(new_seq,sk->copied_seq+1)) /* If the right edge of this frame is after the last copied byte if(after(new_seq,sk->/*copied*/acked_seq+1)) /* If the right edge of this frame is after the last copied byte
then it contains data we will never touch. We send an RST to then it contains data we will never touch. We send an RST to
ensure the far end knows it never got to the application */ ensure the far end knows it never got to the application */
{ {
...@@ -3448,6 +3474,7 @@ static int tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th, ...@@ -3448,6 +3474,7 @@ static int tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th,
*/ */
reset_timer(sk, TIME_CLOSE, TCP_TIMEWAIT_LEN); reset_timer(sk, TIME_CLOSE, TCP_TIMEWAIT_LEN);
/*sk->fin_seq = th->seq+1;*/ /*sk->fin_seq = th->seq+1;*/
sk->shutdown|=SHUTDOWN_MASK;
tcp_set_state(sk,TCP_TIME_WAIT); tcp_set_state(sk,TCP_TIME_WAIT);
break; break;
case TCP_CLOSE: case TCP_CLOSE:
...@@ -3490,7 +3517,7 @@ tcp_accept(struct sock *sk, int flags) ...@@ -3490,7 +3517,7 @@ tcp_accept(struct sock *sk, int flags)
cli(); cli();
sk->inuse = 1; sk->inuse = 1;
while((skb = skb_dequeue(&sk->receive_queue)) == NULL) while((skb = tcp_dequeue_established(sk)) == NULL)
{ {
if (flags & O_NONBLOCK) if (flags & O_NONBLOCK)
{ {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* top level. * top level.
* Alan Cox : Move address structures to/from user * Alan Cox : Move address structures to/from user
* mode above the protocol layers. * mode above the protocol layers.
* Rob Janssen : Allow 0 length sends
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -924,8 +925,6 @@ static int sock_send(int fd, void * buff, int len, unsigned flags) ...@@ -924,8 +925,6 @@ static int sock_send(int fd, void * buff, int len, unsigned flags)
if(len<0) if(len<0)
return -EINVAL; return -EINVAL;
if(len==0)
return 0;
err=verify_area(VERIFY_READ, buff, len); err=verify_area(VERIFY_READ, buff, len);
if(err) if(err)
return err; return err;
...@@ -953,8 +952,6 @@ static int sock_sendto(int fd, void * buff, int len, unsigned flags, ...@@ -953,8 +952,6 @@ static int sock_sendto(int fd, void * buff, int len, unsigned flags,
if(len<0) if(len<0)
return -EINVAL; return -EINVAL;
if(len==0)
return 0;
err=verify_area(VERIFY_READ,buff,len); err=verify_area(VERIFY_READ,buff,len);
if(err) if(err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment