patch-2.1.94 linux/drivers/acorn/net/ether3.c
Next file: linux/drivers/acorn/net/etherh.c
Previous file: linux/drivers/acorn/net/ether1.c
Back to the patch index
Back to the overall index
- Lines: 830
- Date:
Wed Apr 8 15:51:32 1998
- Orig file:
v2.1.93/linux/drivers/acorn/net/ether3.c
- Orig date:
Mon Feb 23 18:12:03 1998
diff -u --recursive --new-file v2.1.93/linux/drivers/acorn/net/ether3.c linux/drivers/acorn/net/ether3.c
@@ -7,29 +7,30 @@
* By Russell King, with some suggestions from borris@ant.co.uk
*
* Changelog:
- * 1.04 RMK 29/02/1996 Won't pass packets that are from our ethernet
- * address up to the higher levels - they're
- * silently ignored. I/F can now be put into
- * multicast mode. Receiver routine optimised.
- * 1.05 RMK 30/02/1996 Now claims interrupt at open when part of
- * the kernel rather than when a module.
- * 1.06 RMK 02/03/1996 Various code cleanups
- * 1.07 RMK 13/10/1996 Optimised interrupt routine and transmit
- * routines.
- * 1.08 RMK 14/10/1996 Fixed problem with too many packets,
- * prevented the kernel message about dropped
- * packets appearing too many times a second.
- * Now does not disable all IRQs, only the IRQ
- * used by this card.
- * 1.09 RMK 10/11/1996 Only enables TX irq when buffer space is low,
- * but we still service the TX queue if we get a
- * RX interrupt.
- * 1.10 RMK 15/07/1997 Fixed autoprobing of NQ8004.
- * 1.11 RMK 16/11/1997 Fixed autoprobing of NQ8005A.
- * 1.12 RMK 31/12/1997 Removed reference to dev_tint for Linux 2.1.
+ * 1.04 RMK 29/02/1996 Won't pass packets that are from our ethernet
+ * address up to the higher levels - they're
+ * silently ignored. I/F can now be put into
+ * multicast mode. Receiver routine optimised.
+ * 1.05 RMK 30/02/1996 Now claims interrupt at open when part of
+ * the kernel rather than when a module.
+ * 1.06 RMK 02/03/1996 Various code cleanups
+ * 1.07 RMK 13/10/1996 Optimised interrupt routine and transmit
+ * routines.
+ * 1.08 RMK 14/10/1996 Fixed problem with too many packets,
+ * prevented the kernel message about dropped
+ * packets appearing too many times a second.
+ * Now does not disable all IRQs, only the IRQ
+ * used by this card.
+ * 1.09 RMK 10/11/1996 Only enables TX irq when buffer space is low,
+ * but we still service the TX queue if we get a
+ * RX interrupt.
+ * 1.10 RMK 15/07/1997 Fixed autoprobing of NQ8004.
+ * 1.11 RMK 16/11/1997 Fixed autoprobing of NQ8005A.
+ * 1.12 RMK 31/12/1997 Removed reference to dev_tint for Linux 2.1.
*
* TODO:
* When we detect a fatal error on the interface, we should restart it.
+ * Reap transmit packets after some time even if the buffer never filled.
*/
static char *version = "ether3 ethernet driver (c) 1995-1998 R.M.King v1.12\n";
@@ -49,6 +50,7 @@
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
+#include <linux/init.h>
#include <asm/system.h>
#include <asm/bitops.h>
@@ -64,25 +66,20 @@
#endif
static unsigned int net_debug = NET_DEBUG;
-
-static const card_ids ether3_cids[] =
-{
- {MANU_ANT2, PROD_ANT_ETHER3},
- {MANU_ANT, PROD_ANT_ETHER3},
- {MANU_ANT, PROD_ANT_ETHERB}, /* trial - will etherb work? */
- {0xffff, 0xffff}
+static const card_ids ether3_cids[] = {
+ { MANU_ANT2, PROD_ANT_ETHER3 },
+ { MANU_ANT, PROD_ANT_ETHER3 },
+ { MANU_ANT, PROD_ANT_ETHERB }, /* trial - will etherb work? */
+ { 0xffff, 0xffff }
};
static void ether3_setmulticastlist(struct device *dev);
-static int ether3_rx(struct device *dev, struct dev_priv *priv, unsigned int maxcnt);
+static int ether3_rx(struct device *dev, struct dev_priv *priv, unsigned int maxcnt);
static void ether3_tx(struct device *dev, struct dev_priv *priv);
extern int inswb(int reg, void *buffer, int len);
extern int outswb(int reg, void *buffer, int len);
-#define struct dev_priv *priv = (struct dev_priv *)dev->priv \
- struct dev_priv *priv = (struct dev_priv *)dev->priv
-
#define BUS_16 2
#define BUS_8 1
#define BUS_UNKNOWN 0
@@ -91,9 +88,7 @@
* I'm not sure what address we should default to if the internal one
* is corrupted...
*/
-
-unsigned char def_eth_addr[6] =
-{0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
+unsigned char def_eth_addr[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
/* --------------------------------------------------------------------------- */
@@ -102,16 +97,17 @@
buffer_read
} buffer_rw_t;
-static int ether3_setbuffer(struct device *dev, buffer_rw_t read, int start)
+static int
+ether3_setbuffer(struct device *dev, buffer_rw_t read, int start)
{
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
int timeout = 1000;
outw(priv->regs.config1 | CFG1_LOCBUFMEM, REG_CONFIG1);
outw(priv->regs.command | CMD_FIFOWRITE, REG_COMMAND);
while ((inw(REG_STATUS) & STAT_FIFOEMPTY) == 0) {
if (!timeout--) {
- printk(KERN_ERR "%s: setbuffer broken\n", dev->name);
+ printk("%s: setbuffer broken\n", dev->name);
priv->broken = 1;
return 1;
}
@@ -131,47 +127,49 @@
* write data to the buffer memory
*/
#define ether3_writebuffer(dev,data,length) \
- outswb (REG_BUFWIN, (data), (length))
+ outswb(REG_BUFWIN, (data), (length))
#define ether3_writeword(dev,data) \
- outw ((data), REG_BUFWIN)
+ outw((data), REG_BUFWIN)
#define ether3_writelong(dev,data) { \
unsigned long reg_bufwin = REG_BUFWIN; \
- outw ((data), reg_bufwin); \
- outw ((data) >> 16, reg_bufwin); \
+ outw((data), reg_bufwin); \
+ outw((data) >> 16, reg_bufwin); \
}
/*
* read data from the buffer memory
*/
#define ether3_readbuffer(dev,data,length) \
- inswb (REG_BUFWIN, (data), (length))
+ inswb(REG_BUFWIN, (data), (length))
#define ether3_readword(dev) \
- inw (REG_BUFWIN)
+ inw(REG_BUFWIN)
#define ether3_readlong(dev) \
- inw (REG_BUFWIN) | (inw (REG_BUFWIN) << 16)
+ inw(REG_BUFWIN) | (inw(REG_BUFWIN) << 16)
/*
* Switch LED off...
*/
-static void ether3_ledoff(unsigned long data)
+static void
+ether3_ledoff(unsigned long data)
{
- struct device *dev = (struct device *) data;
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
+ struct device *dev = (struct device *)data;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
outw(priv->regs.config2 |= CFG2_CTRLO, REG_CONFIG2);
}
/*
* switch LED on...
*/
-static inline void ether3_ledon(struct device *dev, struct dev_priv *priv)
+static inline void
+ether3_ledon(struct device *dev, struct dev_priv *priv)
{
del_timer(&priv->timer);
- priv->timer.expires = jiffies + HZ / 50; /* leave on for 1/50th second */
- priv->timer.data = (unsigned long) dev;
+ priv->timer.expires = jiffies + HZ / 50; /* leave on for 1/50th second */
+ priv->timer.data = (unsigned long)dev;
priv->timer.function = ether3_ledoff;
add_timer(&priv->timer);
if (priv->regs.config2 & CFG2_CTRLO)
@@ -182,30 +180,36 @@
* Read the ethernet address string from the on board rom.
* This is an ascii string!!!
*/
-static void ether3_addr(char *addr, struct expansion_card *ec)
+__initfunc(static void
+ether3_addr(char *addr, struct expansion_card *ec))
{
struct in_chunk_dir cd;
char *s;
-
+
if (ecard_readchunk(&cd, ec, 0xf5, 0) && (s = strchr(cd.d.string, '('))) {
int i;
- for (i = 0; i < 6; i++) {
+ for (i = 0; i<6; i++) {
addr[i] = simple_strtoul(s + 1, &s, 0x10);
- if (*s != (i == 5 ? ')' : ':'))
+ if (*s != (i==5?')' : ':' ))
break;
}
if (i == 6)
return;
}
+ /* I wonder if we should even let the user continue in this case
+ * - no, it would be better to disable the device
+ */
+ printk(KERN_ERR "ether3: Couldn't read a valid MAC address from card.\n");
memcpy(addr, def_eth_addr, 6);
}
/* --------------------------------------------------------------------------- */
-static int ether3_ramtest(struct device *dev, unsigned char byte)
+__initfunc(static int
+ether3_ramtest(struct device *dev, unsigned char byte))
{
unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
- int i, ret = 0;
+ int i,ret = 0;
int max_errors = 4;
int bad = -1;
@@ -234,7 +238,7 @@
}
} else {
if (bad != -1) {
- if (bad != i - 1)
+ if (bad != i - 1)
printk(" - 0x%04X", i - 1);
printk("\n");
bad = -1;
@@ -250,13 +254,14 @@
/* ------------------------------------------------------------------------------- */
-static int ether3_init_2(struct device *dev)
+__initfunc(static int
+ether3_init_2(struct device *dev))
{
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
int i;
- priv->regs.config1 = CFG1_RECVCOMPSTAT0 | CFG1_DMABURST8;
- priv->regs.config2 = CFG2_CTRLO | CFG2_RECVCRC | CFG2_ERRENCRC;
+ priv->regs.config1 = CFG1_RECVCOMPSTAT0|CFG1_DMABURST8;
+ priv->regs.config2 = CFG2_CTRLO|CFG2_RECVCRC|CFG2_ERRENCRC;
priv->regs.command = 0;
/*
* Set up our hardware address
@@ -273,12 +278,12 @@
priv->regs.config1 |= CFG1_RECVSPECBROAD;
/*
- * There is a problem with the NQ8005 in that it occasionally losses the
- * last two bytes. To get round this problem, we receive the CRC as well.
- * That way, if we do loose the last two, then it doesn't matter
+ * There is a problem with the NQ8005 in that it occasionally loses the
+ * last two bytes. To get round this problem, we receive the CRC as
+ * well. That way, if we do loose the last two, then it doesn't matter.
*/
outw(priv->regs.config1 | CFG1_TRANSEND, REG_CONFIG1);
- outw((TX_END >> 8) - 1, REG_BUFWIN);
+ outw((TX_END>>8) - 1, REG_BUFWIN);
outw(priv->rx_head, REG_RECVPTR);
outw(0, REG_TRANSMITPTR);
outw(priv->rx_head >> 8, REG_RECVEND);
@@ -287,10 +292,10 @@
outw(priv->regs.command, REG_COMMAND);
i = ether3_ramtest(dev, 0x5A);
- if (i)
+ if(i)
return i;
i = ether3_ramtest(dev, 0x1E);
- if (i)
+ if(i)
return i;
ether3_setbuffer(dev, buffer_write, 0);
@@ -298,29 +303,30 @@
return 0;
}
-static void ether3_init_for_open(struct device *dev)
+static void
+ether3_init_for_open(struct device *dev)
{
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
int i;
memset(&priv->stats, 0, sizeof(struct enet_statistics));
priv->regs.command = 0;
- outw(CMD_RXOFF | CMD_TXOFF, REG_COMMAND);
- while (inw(REG_STATUS) & (STAT_RXON | STAT_TXON));
+ outw(CMD_RXOFF|CMD_TXOFF, REG_COMMAND);
+ while (inw(REG_STATUS) & (STAT_RXON|STAT_TXON));
outw(priv->regs.config1 | CFG1_BUFSELSTAT0, REG_CONFIG1);
for (i = 0; i < 6; i++)
outb(dev->dev_addr[i], REG_BUFWIN);
- priv->tx_used = 0;
- priv->tx_head = 0;
- priv->tx_tail = 0;
+ priv->tx_used = 0;
+ priv->tx_head = 0;
+ priv->tx_tail = 0;
priv->regs.config2 |= CFG2_CTRLO;
- priv->rx_head = RX_START;
+ priv->rx_head = RX_START;
outw(priv->regs.config1 | CFG1_TRANSEND, REG_CONFIG1);
- outw((TX_END >> 8) - 1, REG_BUFWIN);
+ outw((TX_END>>8) - 1, REG_BUFWIN);
outw(priv->rx_head, REG_RECVPTR);
outw(priv->rx_head >> 8, REG_RECVEND);
outw(0, REG_TRANSMITPTR);
@@ -337,20 +343,22 @@
/*
* This is the real probe routine.
*/
-static int ether3_probe1(struct device *dev)
+__initfunc(static int
+ether3_probe1(struct device *dev))
{
static unsigned version_printed = 0;
struct dev_priv *priv;
unsigned int i, bus_type, error = ENODEV;
- if (net_debug && version_printed++ == 0)
+ if (net_debug && version_printed++ == 0)
printk(version);
if (!dev->priv) {
- dev->priv = kmalloc(sizeof(struct dev_priv), GFP_KERNEL);
+ dev->priv = kmalloc(sizeof (struct dev_priv), GFP_KERNEL);
if (!dev->priv)
return -ENOMEM;
}
+
priv = (struct dev_priv *) dev->priv;
memset(priv, 0, sizeof(struct dev_priv));
@@ -374,6 +382,7 @@
else if (inw(REG_RECVPTR) == 0x101)
bus_type = BUS_16;
}
+
switch (bus_type) {
case BUS_UNKNOWN:
printk(KERN_ERR "%s: unable to identify podule bus width\n", dev->name);
@@ -407,7 +416,8 @@
#endif
return 0;
}
- failed:
+
+failed:
kfree(dev->priv);
dev->priv = NULL;
release_region(dev->base_addr, 128);
@@ -415,7 +425,8 @@
}
#ifndef MODULE
-int ether3_probe(struct device *dev)
+__initfunc(int
+ether3_probe(struct device *dev))
{
struct expansion_card *ec;
@@ -445,7 +456,8 @@
* registers that "should" only need to be set once at boot, so that
* there is non-reboot way to recover if something goes wrong.
*/
-static int ether3_open(struct device *dev)
+static int
+ether3_open(struct device *dev)
{
ether3_init_for_open(dev);
@@ -453,7 +465,7 @@
#ifdef CLAIM_IRQ_AT_OPEN
if (request_irq(dev->irq, ether3_interrupt, 0, "ether3", dev)) {
- MOD_DEC_USE_COUNT;
+ MOD_DEC_USE_COUNT;
return -EAGAIN;
}
#endif
@@ -467,18 +479,19 @@
/*
* The inverse routine to ether3_open().
*/
-static int ether3_close(struct device *dev)
+static int
+ether3_close(struct device *dev)
{
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
dev->tbusy = 1;
dev->start = 0;
disable_irq(dev->irq);
- outw(CMD_RXOFF | CMD_TXOFF, REG_COMMAND);
+ outw(CMD_RXOFF|CMD_TXOFF, REG_COMMAND);
priv->regs.command = 0;
- while (inw(REG_STATUS) & (STAT_RXON | STAT_TXON));
+ while (inw(REG_STATUS) & (STAT_RXON|STAT_TXON));
outb(0x80, REG_CONFIG2 + 1);
outw(0, REG_COMMAND);
@@ -492,12 +505,12 @@
}
/*
- * Get the current statistics. This may be called with the card open or
+ * Get the current statistics. This may be called with the card open or
* closed.
*/
static struct enet_statistics *ether3_getstats(struct device *dev)
{
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
return &priv->stats;
}
@@ -509,14 +522,15 @@
*/
static void ether3_setmulticastlist(struct device *dev)
{
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
priv->regs.config1 &= ~CFG1_RECVPROMISC;
if (dev->flags & IFF_PROMISC) {
/* promiscuous mode */
priv->regs.config1 |= CFG1_RECVPROMISC;
- } else if (dev->flags & IFF_ALLMULTI) {
+ } else
+ if (dev->flags & IFF_ALLMULTI) {
priv->regs.config1 |= CFG1_RECVSPECBRMULTI;
} else
priv->regs.config1 |= CFG1_RECVSPECBROAD;
@@ -527,15 +541,16 @@
/*
* Transmit a packet
*/
-static int ether3_sendpacket(struct sk_buff *skb, struct device *dev)
+static int
+ether3_sendpacket(struct sk_buff *skb, struct device *dev)
{
- struct dev_priv *priv = (struct dev_priv *) dev->priv;
- retry:
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
+retry:
if (!dev->tbusy) {
/* 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 (!test_and_set_bit(0, (void *) &dev->tbusy)) {
+ if (!test_and_set_bit(0, (void *)&dev->tbusy)) {
unsigned long flags;
unsigned int length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
unsigned int ptr, nextptr;
@@ -543,17 +558,18 @@
length = (length + 1) & ~1;
if (priv->broken) {
- dev_kfree_skb(skb, FREE_WRITE);
- priv->stats.tx_dropped++;
+ dev_kfree_skb(skb);
+ priv->stats.tx_dropped ++;
dev->tbusy = 0;
return 0;
}
+
ptr = priv->tx_head;
nextptr = ptr + 0x600;
if (nextptr >= TX_END)
nextptr = 0;
if (nextptr == priv->tx_tail)
- return 1; /* unable to queue */
+ return 1; /* unable to queue */
priv->tx_head = nextptr;
save_flags_cli(flags);
@@ -562,13 +578,13 @@
ether3_setbuffer(dev, buffer_write, ptr + 4);
ether3_writebuffer(dev, skb->data, length);
ether3_writeword(dev, htons(nextptr));
- ether3_writeword(dev, (TXHDR_TRANSMIT | TXHDR_CHAINCONTINUE) >> 16);
+ ether3_writeword(dev, (TXHDR_TRANSMIT|TXHDR_CHAINCONTINUE) >> 16);
ether3_setbuffer(dev, buffer_write, ptr);
#define TXHDR_FLAGS (TXHDR_TRANSMIT|TXHDR_CHAINCONTINUE|TXHDR_DATAFOLLOWS|TXHDR_ENSUCCESS)
ether3_writeword(dev, htons(ptr + length + 4));
ether3_writeword(dev, (TXHDR_FLAGS >> 16));
ether3_ledon(dev, priv);
- priv->tx_used++;
+ priv->tx_used ++;
if (priv->tx_used < MAX_TX_BUFFERED)
dev->tbusy = 0;
if (priv->tx_used >= (MAX_TX_BUFFERED * 3 / 4)) {
@@ -578,7 +594,7 @@
restore_flags(flags);
dev->trans_start = jiffies;
- dev_kfree_skb(skb, FREE_WRITE);
+ dev_kfree_skb(skb);
if (!(inw(REG_STATUS) & STAT_TXON)) {
outw(ptr, REG_TRANSMITPTR);
outw(priv->regs.command | CMD_TXON, REG_COMMAND);
@@ -599,24 +615,25 @@
printk("%s: transmit timed out, network cable problem?\n", dev->name);
dev->tbusy = 0;
priv->regs.config2 |= CFG2_CTRLO;
- outw(priv->regs.config2, REG_CONFIG2);
+ outw(priv->regs.config2 , REG_CONFIG2);
dev->trans_start = jiffies;
goto retry;
}
}
-static void ether3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static void
+ether3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
- struct device *dev = (struct device *) dev_id;
+ struct device *dev = (struct device *)dev_id;
struct dev_priv *priv;
unsigned int status;
#if NET_DEBUG > 1
- if (net_debug & DEBUG_INT)
+ if(net_debug & DEBUG_INT)
printk("eth3irq: %d ", irq);
#endif
- priv = (struct dev_priv *) dev->priv;
+ priv = (struct dev_priv *)dev->priv;
dev->interrupt = 1;
status = inw(REG_STATUS);
@@ -625,12 +642,13 @@
* mostly empty, if we happen to get a RX interrupt, we might as
* well handle the TX packets as well.
*/
- if (status & STAT_INTTX) { /* Packets transmitted */
+ if (status & STAT_INTTX) { /* Packets transmitted */
outw(CMD_ACKINTTX | priv->regs.command, REG_COMMAND);
ether3_tx(dev, priv);
}
+
status = inw(REG_STATUS);
- if (status & STAT_INTRX && ether3_rx(dev, priv, 12)) { /* Got packet(s). */
+ if (status & STAT_INTRX && ether3_rx(dev, priv, 12)) { /* Got packet(s). */
/*
* We only acknowledge the interrupt if we have received all packets
* in the buffer or else we run out of memory. This is to allow the
@@ -646,7 +664,7 @@
dev->interrupt = 0;
#if NET_DEBUG > 1
- if (net_debug & DEBUG_INT)
+ if(net_debug & DEBUG_INT)
printk("done\n");
#endif
}
@@ -654,7 +672,8 @@
/*
* If we have a good packet(s), get it/them out of the buffers.
*/
-static int ether3_rx(struct device *dev, struct dev_priv *priv, unsigned int maxcnt)
+static int
+ether3_rx(struct device *dev, struct dev_priv *priv, unsigned int maxcnt)
{
unsigned int next_ptr = priv->rx_head, received = 0;
ether3_ledon(dev, priv);
@@ -681,16 +700,17 @@
next_ptr = ntohs(temp_ptr);
}
ether3_setbuffer(dev, buffer_read, this_ptr);
- ether3_readbuffer(dev, addrs + 2, 12);
+ ether3_readbuffer(dev, addrs+2, 12);
/*
- * ignore our own packets...
- */
- if (!(*(unsigned long *) &dev->dev_addr[0] ^ *(unsigned long *) &addrs[2 + 6]) &&
- !(*(unsigned short *) &dev->dev_addr[4] ^ *(unsigned short *) &addrs[2 + 10])) {
- maxcnt++; /* compensate for loopedback packet */
+ * ignore our own packets...
+ */
+ if (!(*(unsigned long *)&dev->dev_addr[0] ^ *(unsigned long *)&addrs[2+6]) &&
+ !(*(unsigned short *)&dev->dev_addr[4] ^ *(unsigned short *)&addrs[2+10])) {
+ maxcnt ++; /* compensate for loopedback packet */
outw(next_ptr >> 8, REG_RECVEND);
- } else if (!(status & (RXSTAT_OVERSIZE | RXSTAT_CRCERROR | RXSTAT_DRIBBLEERROR | RXSTAT_SHORTPACKET))) {
+ } else
+ if (!(status & (RXSTAT_OVERSIZE|RXSTAT_CRCERROR|RXSTAT_DRIBBLEERROR|RXSTAT_SHORTPACKET))) {
unsigned int length = next_ptr - this_ptr;
struct sk_buff *skb;
@@ -706,32 +726,28 @@
buf = skb_put(skb, length);
ether3_readbuffer(dev, buf + 12, length - 12);
outw(next_ptr >> 8, REG_RECVEND);
- *(unsigned short *) (buf + 0) = *(unsigned short *) (addrs + 2);
- *(unsigned long *) (buf + 2) = *(unsigned long *) (addrs + 4);
- *(unsigned long *) (buf + 6) = *(unsigned long *) (addrs + 8);
- *(unsigned short *) (buf + 10) = *(unsigned short *) (addrs + 12);
+ *(unsigned short *)(buf + 0) = *(unsigned short *)(addrs + 2);
+ *(unsigned long *)(buf + 2) = *(unsigned long *)(addrs + 4);
+ *(unsigned long *)(buf + 6) = *(unsigned long *)(addrs + 8);
+ *(unsigned short *)(buf + 10) = *(unsigned short *)(addrs + 12);
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
- received++;
+ received ++;
} else
goto dropping;
} else {
struct enet_statistics *stats = &priv->stats;
outw(next_ptr >> 8, REG_RECVEND);
- if (status & RXSTAT_OVERSIZE)
- stats->rx_length_errors++;
- if (status & RXSTAT_CRCERROR)
- stats->rx_crc_errors++;
- if (status & RXSTAT_DRIBBLEERROR)
- stats->rx_fifo_errors++;
- if (status & RXSTAT_SHORTPACKET)
- stats->rx_length_errors++;
+ if (status & RXSTAT_OVERSIZE) stats->rx_length_errors ++;
+ if (status & RXSTAT_CRCERROR) stats->rx_crc_errors ++;
+ if (status & RXSTAT_DRIBBLEERROR) stats->rx_fifo_errors ++;
+ if (status & RXSTAT_SHORTPACKET) stats->rx_length_errors ++;
stats->rx_errors++;
}
}
- while (--maxcnt);
+ while (-- maxcnt);
- done:
+done:
priv->stats.rx_packets += received;
priv->rx_head = next_ptr;
/*
@@ -739,42 +755,44 @@
* have dropped at least one packet.
*/
if (!(inw(REG_STATUS) & STAT_RXON)) {
- priv->stats.rx_dropped++;
- outw(next_ptr, REG_RECVPTR);
+ priv->stats.rx_dropped ++;
+ outw(next_ptr, REG_RECVPTR);
outw(priv->regs.command | CMD_RXON, REG_COMMAND);
}
+
return maxcnt;
- dropping:{
- static unsigned long last_warned;
+dropping:{
+ static unsigned long last_warned;
- outw(next_ptr >> 8, REG_RECVEND);
- /*
- * Don't print this message too many times...
- */
- if (jiffies - last_warned > 30 * HZ) {
- last_warned = jiffies;
- printk("%s: memory squeeze, dropping packet.\n", dev->name);
- }
- priv->stats.rx_dropped++;
- goto done;
+ outw(next_ptr >> 8, REG_RECVEND);
+ /*
+ * Don't print this message too many times...
+ */
+ if (jiffies - last_warned > 30 * HZ) {
+ last_warned = jiffies;
+ printk("%s: memory squeeze, dropping packet.\n", dev->name);
+ }
+ priv->stats.rx_dropped ++;
+ goto done;
}
}
/*
* Update stats for the transmitted packet(s)
*/
-static void ether3_tx(struct device *dev, struct dev_priv *priv)
+static void
+ether3_tx(struct device *dev, struct dev_priv *priv)
{
unsigned int tx_tail = priv->tx_tail;
do {
- unsigned long status;
- /*
- * Read the packet header
- */
- ether3_setbuffer(dev, buffer_read, tx_tail);
- status = ether3_readlong(dev);
+ unsigned long status;
+ /*
+ * Read the packet header
+ */
+ ether3_setbuffer(dev, buffer_read, tx_tail);
+ status = ether3_readlong(dev);
/*
* Check to see if this packet has been transmitted
@@ -788,11 +806,9 @@
if (!(status & (TXSTAT_BABBLED | TXSTAT_16COLLISIONS)))
priv->stats.tx_packets++;
else {
- priv->stats.tx_errors++;
- if (status & TXSTAT_16COLLISIONS)
- priv->stats.collisions += 16;
- if (status & TXSTAT_BABBLED)
- priv->stats.tx_fifo_errors++;
+ priv->stats.tx_errors ++;
+ if (status & TXSTAT_16COLLISIONS) priv->stats.collisions += 16;
+ if (status & TXSTAT_BABBLED) priv->stats.tx_fifo_errors ++;
}
/*
@@ -824,11 +840,12 @@
static struct device *my_ethers[MAX_ECARDS];
static struct expansion_card *ec[MAX_ECARDS];
-int init_module(void)
+int
+init_module(void)
{
int i;
- for (i = 0; i < MAX_ECARDS; i++) {
+ for(i = 0; i < MAX_ECARDS; i++) {
my_ethers[i] = NULL;
ec[i] = NULL;
strcpy(ethernames[i], " ");
@@ -842,11 +859,11 @@
if ((ec[i] = ecard_find(0, ether3_cids)) == NULL)
break;
- my_ethers[i] = (struct device *) kmalloc(sizeof(struct device), GFP_KERNEL);
+ my_ethers[i] = (struct device *)kmalloc(sizeof(struct device), GFP_KERNEL);
memset(my_ethers[i], 0, sizeof(struct device));
my_ethers[i]->irq = ec[i]->irq;
- my_ethers[i]->base_addr = ecard_address(ec[i], ECARD_MEMC, 0);
+ my_ethers[i]->base_addr= ecard_address(ec[i], ECARD_MEMC, 0);
my_ethers[i]->init = ether3_probe1;
my_ethers[i]->name = ethernames[i];
@@ -854,13 +871,13 @@
ecard_claim(ec[i]);
- if (register_netdev(my_ethers[i]) != 0) {
+ if(register_netdev(my_ethers[i]) != 0) {
for (i = 0; i < 4; i++) {
- if (my_ethers[i]) {
+ if(my_ethers[i]) {
kfree(my_ethers[i]);
my_ethers[i] = NULL;
}
- if (ec[i]) {
+ if(ec[i]) {
ecard_release(ec[i]);
ec[i] = NULL;
}
@@ -869,28 +886,25 @@
}
i++;
}
- while (i < MAX_ECARDS);
+ while(i < MAX_ECARDS);
return i != 0 ? 0 : -ENODEV;
}
-void cleanup_module(void)
+void
+cleanup_module(void)
{
- if (MOD_IN_USE) {
- printk("ether3: device busy, remove delayed\n");
- } else {
- int i;
- for (i = 0; i < MAX_ECARDS; i++) {
- if (my_ethers[i]) {
- release_region(my_ethers[i]->base_addr, 128);
- unregister_netdev(my_ethers[i]);
- my_ethers[i] = NULL;
- }
- if (ec[i]) {
- ecard_release(ec[i]);
- ec[i] = NULL;
- }
+ int i;
+ for (i = 0; i < MAX_ECARDS; i++) {
+ if (my_ethers[i]) {
+ release_region(my_ethers[i]->base_addr, 128);
+ unregister_netdev(my_ethers[i]);
+ my_ethers[i] = NULL;
+ }
+ if (ec[i]) {
+ ecard_release(ec[i]);
+ ec[i] = NULL;
}
}
}
-#endif /* MODULE */
+#endif /* MODULE */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov