2 * linux/drivers/acorn/net/ether3.c
4 * Copyright (C) 1995-2000 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * SEEQ nq8005 ethernet driver for Acorn/ANT Ether3 card
13 * By Russell King, with some suggestions from borris@ant.co.uk
16 * 1.04 RMK 29/02/1996 Won't pass packets that are from our ethernet
17 * address up to the higher levels - they're
18 * silently ignored. I/F can now be put into
19 * multicast mode. Receiver routine optimised.
20 * 1.05 RMK 30/02/1996 Now claims interrupt at open when part of
21 * the kernel rather than when a module.
22 * 1.06 RMK 02/03/1996 Various code cleanups
23 * 1.07 RMK 13/10/1996 Optimised interrupt routine and transmit
25 * 1.08 RMK 14/10/1996 Fixed problem with too many packets,
26 * prevented the kernel message about dropped
27 * packets appearing too many times a second.
28 * Now does not disable all IRQs, only the IRQ
30 * 1.09 RMK 10/11/1996 Only enables TX irq when buffer space is low,
31 * but we still service the TX queue if we get a
33 * 1.10 RMK 15/07/1997 Fixed autoprobing of NQ8004.
34 * 1.11 RMK 16/11/1997 Fixed autoprobing of NQ8005A.
35 * 1.12 RMK 31/12/1997 Removed reference to dev_tint for Linux 2.1.
36 * RMK 27/06/1998 Changed asm/delay.h to linux/delay.h.
37 * 1.13 RMK 29/06/1998 Fixed problem with transmission of packets.
38 * Chip seems to have a bug in, whereby if the
39 * packet starts two bytes from the end of the
40 * buffer, it corrupts the receiver chain, and
41 * never updates the transmit status correctly.
42 * 1.14 RMK 07/01/1998 Added initial code for ETHERB addressing.
43 * 1.15 RMK 30/04/1999 More fixes to the transmit routine for buggy
45 * 1.16 RMK 10/02/2000 Updated for 2.3.43
46 * 1.17 RMK 13/05/2000 Updated for 2.3.99-pre8
49 #include <linux/module.h>
50 #include <linux/kernel.h>
51 #include <linux/sched.h>
52 #include <linux/types.h>
53 #include <linux/fcntl.h>
54 #include <linux/interrupt.h>
55 #include <linux/ptrace.h>
56 #include <linux/ioport.h>
58 #include <linux/slab.h>
59 #include <linux/string.h>
60 #include <linux/errno.h>
61 #include <linux/netdevice.h>
62 #include <linux/etherdevice.h>
63 #include <linux/skbuff.h>
64 #include <linux/device.h>
65 #include <linux/init.h>
66 #include <linux/delay.h>
68 #include <asm/system.h>
69 #include <asm/bitops.h>
70 #include <asm/ecard.h>
74 static char version[] __initdata = "ether3 ethernet driver (c) 1995-2000 R.M.King v1.17\n";
78 static unsigned int net_debug = NET_DEBUG;
80 static void ether3_setmulticastlist(struct net_device *dev);
81 static int ether3_rx(struct net_device *dev, struct dev_priv *priv, unsigned int maxcnt);
82 static void ether3_tx(struct net_device *dev, struct dev_priv *priv);
83 static int ether3_open (struct net_device *dev);
84 static int ether3_sendpacket (struct sk_buff *skb, struct net_device *dev);
85 static irqreturn_t ether3_interrupt (int irq, void *dev_id, struct pt_regs *regs);
86 static int ether3_close (struct net_device *dev);
87 static struct net_device_stats *ether3_getstats (struct net_device *dev);
88 static void ether3_setmulticastlist (struct net_device *dev);
89 static void ether3_timeout(struct net_device *dev);
95 /* --------------------------------------------------------------------------- */
103 * ether3 read/write. Slow things down a bit...
104 * The SEEQ8005 doesn't like us writing to its registers
107 static inline void ether3_outb(int v, const int r)
113 static inline void ether3_outw(int v, const int r)
118 #define ether3_inb(r) ({ unsigned int __v = inb((r)); udelay(1); __v; })
119 #define ether3_inw(r) ({ unsigned int __v = inw((r)); udelay(1); __v; })
122 ether3_setbuffer(struct net_device *dev, buffer_rw_t read, int start)
124 struct dev_priv *priv = (struct dev_priv *)dev->priv;
127 ether3_outw(priv->regs.config1 | CFG1_LOCBUFMEM, REG_CONFIG1);
128 ether3_outw(priv->regs.command | CMD_FIFOWRITE, REG_COMMAND);
130 while ((ether3_inw(REG_STATUS) & STAT_FIFOEMPTY) == 0) {
132 printk("%s: setbuffer broken\n", dev->name);
139 if (read == buffer_read) {
140 ether3_outw(start, REG_DMAADDR);
141 ether3_outw(priv->regs.command | CMD_FIFOREAD, REG_COMMAND);
143 ether3_outw(priv->regs.command | CMD_FIFOWRITE, REG_COMMAND);
144 ether3_outw(start, REG_DMAADDR);
150 * write data to the buffer memory
152 #define ether3_writebuffer(dev,data,length) \
153 outsw(REG_BUFWIN, (data), (length) >> 1)
155 #define ether3_writeword(dev,data) \
156 outw((data), REG_BUFWIN)
158 #define ether3_writelong(dev,data) { \
159 unsigned long reg_bufwin = REG_BUFWIN; \
160 outw((data), reg_bufwin); \
161 outw((data) >> 16, reg_bufwin); \
165 * read data from the buffer memory
167 #define ether3_readbuffer(dev,data,length) \
168 insw(REG_BUFWIN, (data), (length) >> 1)
170 #define ether3_readword(dev) \
173 #define ether3_readlong(dev) \
174 inw(REG_BUFWIN) | (inw(REG_BUFWIN) << 16)
180 ether3_ledoff(unsigned long data)
182 struct net_device *dev = (struct net_device *)data;
183 struct dev_priv *priv = (struct dev_priv *)dev->priv;
184 ether3_outw(priv->regs.config2 |= CFG2_CTRLO, REG_CONFIG2);
191 ether3_ledon(struct net_device *dev, struct dev_priv *priv)
193 del_timer(&priv->timer);
194 priv->timer.expires = jiffies + HZ / 50; /* leave on for 1/50th second */
195 priv->timer.data = (unsigned long)dev;
196 priv->timer.function = ether3_ledoff;
197 add_timer(&priv->timer);
198 if (priv->regs.config2 & CFG2_CTRLO)
199 ether3_outw(priv->regs.config2 &= ~CFG2_CTRLO, REG_CONFIG2);
203 * Read the ethernet address string from the on board rom.
204 * This is an ascii string!!!
207 ether3_addr(char *addr, struct expansion_card *ec)
209 struct in_chunk_dir cd;
212 if (ecard_readchunk(&cd, ec, 0xf5, 0) && (s = strchr(cd.d.string, '('))) {
214 for (i = 0; i<6; i++) {
215 addr[i] = simple_strtoul(s + 1, &s, 0x10);
216 if (*s != (i==5?')' : ':' ))
222 /* I wonder if we should even let the user continue in this case
223 * - no, it would be better to disable the device
225 printk(KERN_ERR "ether3: Couldn't read a valid MAC address from card.\n");
229 /* --------------------------------------------------------------------------- */
232 ether3_ramtest(struct net_device *dev, unsigned char byte)
234 unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
242 memset(buffer, byte, RX_END);
243 ether3_setbuffer(dev, buffer_write, 0);
244 ether3_writebuffer(dev, buffer, TX_END);
245 ether3_setbuffer(dev, buffer_write, RX_START);
246 ether3_writebuffer(dev, buffer + RX_START, RX_LEN);
247 memset(buffer, byte ^ 0xff, RX_END);
248 ether3_setbuffer(dev, buffer_read, 0);
249 ether3_readbuffer(dev, buffer, TX_END);
250 ether3_setbuffer(dev, buffer_read, RX_START);
251 ether3_readbuffer(dev, buffer + RX_START, RX_LEN);
253 for (i = 0; i < RX_END; i++) {
254 if (buffer[i] != byte) {
255 if (max_errors > 0 && bad != buffer[i]) {
256 printk("%s: RAM failed with (%02X instead of %02X) at 0x%04X",
257 dev->name, buffer[i], byte, i);
265 printk(" - 0x%04X\n", i - 1);
272 printk(" - 0xffff\n");
278 /* ------------------------------------------------------------------------------- */
281 ether3_init_2(struct net_device *dev)
283 struct dev_priv *priv = (struct dev_priv *)dev->priv;
286 priv->regs.config1 = CFG1_RECVCOMPSTAT0|CFG1_DMABURST8;
287 priv->regs.config2 = CFG2_CTRLO|CFG2_RECVCRC|CFG2_ERRENCRC;
288 priv->regs.command = 0;
291 * Set up our hardware address
293 ether3_outw(priv->regs.config1 | CFG1_BUFSELSTAT0, REG_CONFIG1);
294 for (i = 0; i < 6; i++)
295 ether3_outb(dev->dev_addr[i], REG_BUFWIN);
297 if (dev->flags & IFF_PROMISC)
298 priv->regs.config1 |= CFG1_RECVPROMISC;
299 else if (dev->flags & IFF_MULTICAST)
300 priv->regs.config1 |= CFG1_RECVSPECBRMULTI;
302 priv->regs.config1 |= CFG1_RECVSPECBROAD;
305 * There is a problem with the NQ8005 in that it occasionally loses the
306 * last two bytes. To get round this problem, we receive the CRC as
307 * well. That way, if we do lose the last two, then it doesn't matter.
309 ether3_outw(priv->regs.config1 | CFG1_TRANSEND, REG_CONFIG1);
310 ether3_outw((TX_END>>8) - 1, REG_BUFWIN);
311 ether3_outw(priv->rx_head, REG_RECVPTR);
312 ether3_outw(0, REG_TRANSMITPTR);
313 ether3_outw(priv->rx_head >> 8, REG_RECVEND);
314 ether3_outw(priv->regs.config2, REG_CONFIG2);
315 ether3_outw(priv->regs.config1 | CFG1_LOCBUFMEM, REG_CONFIG1);
316 ether3_outw(priv->regs.command, REG_COMMAND);
318 i = ether3_ramtest(dev, 0x5A);
321 i = ether3_ramtest(dev, 0x1E);
325 ether3_setbuffer(dev, buffer_write, 0);
326 ether3_writelong(dev, 0);
331 ether3_init_for_open(struct net_device *dev)
333 struct dev_priv *priv = (struct dev_priv *)dev->priv;
336 memset(&priv->stats, 0, sizeof(struct net_device_stats));
339 ether3_outw(CFG2_RESET, REG_CONFIG2);
342 priv->regs.command = 0;
343 ether3_outw(CMD_RXOFF|CMD_TXOFF, REG_COMMAND);
344 while (ether3_inw(REG_STATUS) & (STAT_RXON|STAT_TXON));
346 ether3_outw(priv->regs.config1 | CFG1_BUFSELSTAT0, REG_CONFIG1);
347 for (i = 0; i < 6; i++)
348 ether3_outb(dev->dev_addr[i], REG_BUFWIN);
352 priv->regs.config2 |= CFG2_CTRLO;
353 priv->rx_head = RX_START;
355 ether3_outw(priv->regs.config1 | CFG1_TRANSEND, REG_CONFIG1);
356 ether3_outw((TX_END>>8) - 1, REG_BUFWIN);
357 ether3_outw(priv->rx_head, REG_RECVPTR);
358 ether3_outw(priv->rx_head >> 8, REG_RECVEND);
359 ether3_outw(0, REG_TRANSMITPTR);
360 ether3_outw(priv->regs.config2, REG_CONFIG2);
361 ether3_outw(priv->regs.config1 | CFG1_LOCBUFMEM, REG_CONFIG1);
363 ether3_setbuffer(dev, buffer_write, 0);
364 ether3_writelong(dev, 0);
366 priv->regs.command = CMD_ENINTRX | CMD_ENINTTX;
367 ether3_outw(priv->regs.command | CMD_RXON, REG_COMMAND);
371 ether3_probe_bus_8(struct net_device *dev, int val)
373 int write_low, write_high, read_low, read_high;
375 write_low = val & 255;
376 write_high = val >> 8;
378 printk(KERN_DEBUG "ether3_probe: write8 [%02X:%02X]", write_high, write_low);
380 ether3_outb(write_low, REG_RECVPTR);
381 ether3_outb(write_high, REG_RECVPTR + 1);
383 read_low = ether3_inb(REG_RECVPTR);
384 read_high = ether3_inb(REG_RECVPTR + 1);
386 printk(", read8 [%02X:%02X]\n", read_high, read_low);
388 return read_low == write_low && read_high == write_high;
392 ether3_probe_bus_16(struct net_device *dev, int val)
396 ether3_outw(val, REG_RECVPTR);
397 read_val = ether3_inw(REG_RECVPTR);
399 printk(KERN_DEBUG "ether3_probe: write16 [%04X], read16 [%04X]\n", val, read_val);
401 return read_val == val;
405 * Open/initialize the board. This is called (in the current kernel)
406 * sometime after booting when the 'ifconfig' program is run.
408 * This routine should set everything up anew at each open, even
409 * registers that "should" only need to be set once at boot, so that
410 * there is non-reboot way to recover if something goes wrong.
413 ether3_open(struct net_device *dev)
415 if (!is_valid_ether_addr(dev->dev_addr)) {
416 printk(KERN_WARNING "%s: invalid ethernet MAC address\n",
421 if (request_irq(dev->irq, ether3_interrupt, 0, "ether3", dev))
424 ether3_init_for_open(dev);
426 netif_start_queue(dev);
432 * The inverse routine to ether3_open().
435 ether3_close(struct net_device *dev)
437 struct dev_priv *priv = (struct dev_priv *)dev->priv;
439 netif_stop_queue(dev);
441 disable_irq(dev->irq);
443 ether3_outw(CMD_RXOFF|CMD_TXOFF, REG_COMMAND);
444 priv->regs.command = 0;
445 while (ether3_inw(REG_STATUS) & (STAT_RXON|STAT_TXON));
446 ether3_outb(0x80, REG_CONFIG2 + 1);
447 ether3_outw(0, REG_COMMAND);
449 free_irq(dev->irq, dev);
455 * Get the current statistics. This may be called with the card open or
458 static struct net_device_stats *ether3_getstats(struct net_device *dev)
460 struct dev_priv *priv = (struct dev_priv *)dev->priv;
465 * Set or clear promiscuous/multicast mode filter for this adaptor.
467 * We don't attempt any packet filtering. The card may have a SEEQ 8004
468 * in which does not have the other ethernet address registers present...
470 static void ether3_setmulticastlist(struct net_device *dev)
472 struct dev_priv *priv = (struct dev_priv *)dev->priv;
474 priv->regs.config1 &= ~CFG1_RECVPROMISC;
476 if (dev->flags & IFF_PROMISC) {
477 /* promiscuous mode */
478 priv->regs.config1 |= CFG1_RECVPROMISC;
479 } else if (dev->flags & IFF_ALLMULTI) {
480 priv->regs.config1 |= CFG1_RECVSPECBRMULTI;
482 priv->regs.config1 |= CFG1_RECVSPECBROAD;
484 ether3_outw(priv->regs.config1 | CFG1_LOCBUFMEM, REG_CONFIG1);
488 ether3_timeout(struct net_device *dev)
490 struct dev_priv *priv = (struct dev_priv *)dev->priv;
493 del_timer(&priv->timer);
495 local_irq_save(flags);
496 printk(KERN_ERR "%s: transmit timed out, network cable problem?\n", dev->name);
497 printk(KERN_ERR "%s: state: { status=%04X cfg1=%04X cfg2=%04X }\n", dev->name,
498 ether3_inw(REG_STATUS), ether3_inw(REG_CONFIG1), ether3_inw(REG_CONFIG2));
499 printk(KERN_ERR "%s: { rpr=%04X rea=%04X tpr=%04X }\n", dev->name,
500 ether3_inw(REG_RECVPTR), ether3_inw(REG_RECVEND), ether3_inw(REG_TRANSMITPTR));
501 printk(KERN_ERR "%s: tx head=%X tx tail=%X\n", dev->name,
502 priv->tx_head, priv->tx_tail);
503 ether3_setbuffer(dev, buffer_read, priv->tx_tail);
504 printk(KERN_ERR "%s: packet status = %08X\n", dev->name, ether3_readlong(dev));
505 local_irq_restore(flags);
507 priv->regs.config2 |= CFG2_CTRLO;
508 priv->stats.tx_errors += 1;
509 ether3_outw(priv->regs.config2, REG_CONFIG2);
510 priv->tx_head = priv->tx_tail = 0;
512 netif_wake_queue(dev);
519 ether3_sendpacket(struct sk_buff *skb, struct net_device *dev)
521 struct dev_priv *priv = (struct dev_priv *)dev->priv;
523 unsigned int length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
524 unsigned int ptr, next_ptr;
526 length = (length + 1) & ~1;
530 priv->stats.tx_dropped ++;
531 netif_start_queue(dev);
535 next_ptr = (priv->tx_head + 1) & 15;
537 local_irq_save(flags);
539 if (priv->tx_tail == next_ptr) {
540 local_irq_restore(flags);
541 return 1; /* unable to queue */
544 dev->trans_start = jiffies;
545 ptr = 0x600 * priv->tx_head;
546 priv->tx_head = next_ptr;
549 #define TXHDR_FLAGS (TXHDR_TRANSMIT|TXHDR_CHAINCONTINUE|TXHDR_DATAFOLLOWS|TXHDR_ENSUCCESS)
551 ether3_setbuffer(dev, buffer_write, next_ptr);
552 ether3_writelong(dev, 0);
553 ether3_setbuffer(dev, buffer_write, ptr);
554 ether3_writelong(dev, 0);
555 ether3_writebuffer(dev, skb->data, length);
556 ether3_writeword(dev, htons(next_ptr));
557 ether3_writeword(dev, TXHDR_CHAINCONTINUE >> 16);
558 ether3_setbuffer(dev, buffer_write, ptr);
559 ether3_writeword(dev, htons((ptr + length + 4)));
560 ether3_writeword(dev, TXHDR_FLAGS >> 16);
561 ether3_ledon(dev, priv);
563 if (!(ether3_inw(REG_STATUS) & STAT_TXON)) {
564 ether3_outw(ptr, REG_TRANSMITPTR);
565 ether3_outw(priv->regs.command | CMD_TXON, REG_COMMAND);
568 next_ptr = (priv->tx_head + 1) & 15;
569 local_irq_restore(flags);
573 if (priv->tx_tail == next_ptr)
574 netif_stop_queue(dev);
580 ether3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
582 struct net_device *dev = (struct net_device *)dev_id;
583 struct dev_priv *priv;
584 unsigned int status, handled = IRQ_NONE;
587 if(net_debug & DEBUG_INT)
588 printk("eth3irq: %d ", irq);
591 priv = (struct dev_priv *)dev->priv;
593 status = ether3_inw(REG_STATUS);
595 if (status & STAT_INTRX) {
596 ether3_outw(CMD_ACKINTRX | priv->regs.command, REG_COMMAND);
597 ether3_rx(dev, priv, 12);
598 handled = IRQ_HANDLED;
601 if (status & STAT_INTTX) {
602 ether3_outw(CMD_ACKINTTX | priv->regs.command, REG_COMMAND);
603 ether3_tx(dev, priv);
604 handled = IRQ_HANDLED;
608 if(net_debug & DEBUG_INT)
615 * If we have a good packet(s), get it/them out of the buffers.
618 ether3_rx(struct net_device *dev, struct dev_priv *priv, unsigned int maxcnt)
620 unsigned int next_ptr = priv->rx_head, received = 0;
621 ether3_ledon(dev, priv);
624 unsigned int this_ptr, status;
625 unsigned char addrs[16];
628 * read the first 16 bytes from the buffer.
629 * This contains the status bytes etc and ethernet addresses,
630 * and we also check the source ethernet address to see if
631 * it originated from us.
634 unsigned int temp_ptr;
635 ether3_setbuffer(dev, buffer_read, next_ptr);
636 temp_ptr = ether3_readword(dev);
637 status = ether3_readword(dev);
638 if ((status & (RXSTAT_DONE | RXHDR_CHAINCONTINUE | RXHDR_RECEIVE)) !=
639 (RXSTAT_DONE | RXHDR_CHAINCONTINUE) || !temp_ptr)
642 this_ptr = next_ptr + 4;
643 next_ptr = ntohs(temp_ptr);
645 ether3_setbuffer(dev, buffer_read, this_ptr);
646 ether3_readbuffer(dev, addrs+2, 12);
648 if (next_ptr < RX_START || next_ptr >= RX_END) {
650 printk("%s: bad next pointer @%04X: ", dev->name, priv->rx_head);
651 printk("%02X %02X %02X %02X ", next_ptr >> 8, next_ptr & 255, status & 255, status >> 8);
652 for (i = 2; i < 14; i++)
653 printk("%02X ", addrs[i]);
655 next_ptr = priv->rx_head;
659 * ignore our own packets...
661 if (!(*(unsigned long *)&dev->dev_addr[0] ^ *(unsigned long *)&addrs[2+6]) &&
662 !(*(unsigned short *)&dev->dev_addr[4] ^ *(unsigned short *)&addrs[2+10])) {
663 maxcnt ++; /* compensate for loopedback packet */
664 ether3_outw(next_ptr >> 8, REG_RECVEND);
666 if (!(status & (RXSTAT_OVERSIZE|RXSTAT_CRCERROR|RXSTAT_DRIBBLEERROR|RXSTAT_SHORTPACKET))) {
667 unsigned int length = next_ptr - this_ptr;
670 if (next_ptr <= this_ptr)
671 length += RX_END - RX_START;
673 skb = dev_alloc_skb(length + 2);
679 buf = skb_put(skb, length);
680 ether3_readbuffer(dev, buf + 12, length - 12);
681 ether3_outw(next_ptr >> 8, REG_RECVEND);
682 *(unsigned short *)(buf + 0) = *(unsigned short *)(addrs + 2);
683 *(unsigned long *)(buf + 2) = *(unsigned long *)(addrs + 4);
684 *(unsigned long *)(buf + 6) = *(unsigned long *)(addrs + 8);
685 *(unsigned short *)(buf + 10) = *(unsigned short *)(addrs + 12);
686 skb->protocol = eth_type_trans(skb, dev);
692 struct net_device_stats *stats = &priv->stats;
693 ether3_outw(next_ptr >> 8, REG_RECVEND);
694 if (status & RXSTAT_OVERSIZE) stats->rx_over_errors ++;
695 if (status & RXSTAT_CRCERROR) stats->rx_crc_errors ++;
696 if (status & RXSTAT_DRIBBLEERROR) stats->rx_fifo_errors ++;
697 if (status & RXSTAT_SHORTPACKET) stats->rx_length_errors ++;
704 priv->stats.rx_packets += received;
705 priv->rx_head = next_ptr;
707 * If rx went off line, then that means that the buffer may be full. We
708 * have dropped at least one packet.
710 if (!(ether3_inw(REG_STATUS) & STAT_RXON)) {
711 priv->stats.rx_dropped ++;
712 ether3_outw(next_ptr, REG_RECVPTR);
713 ether3_outw(priv->regs.command | CMD_RXON, REG_COMMAND);
719 static unsigned long last_warned;
721 ether3_outw(next_ptr >> 8, REG_RECVEND);
723 * Don't print this message too many times...
725 if (time_after(jiffies, last_warned + 10 * HZ)) {
726 last_warned = jiffies;
727 printk("%s: memory squeeze, dropping packet.\n", dev->name);
729 priv->stats.rx_dropped ++;
735 * Update stats for the transmitted packet(s)
738 ether3_tx(struct net_device *dev, struct dev_priv *priv)
740 unsigned int tx_tail = priv->tx_tail;
744 unsigned long status;
747 * Read the packet header
749 ether3_setbuffer(dev, buffer_read, tx_tail * 0x600);
750 status = ether3_readlong(dev);
753 * Check to see if this packet has been transmitted
755 if ((status & (TXSTAT_DONE | TXHDR_TRANSMIT)) !=
756 (TXSTAT_DONE | TXHDR_TRANSMIT))
762 if (!(status & (TXSTAT_BABBLED | TXSTAT_16COLLISIONS)))
763 priv->stats.tx_packets++;
765 priv->stats.tx_errors ++;
766 if (status & TXSTAT_16COLLISIONS) priv->stats.collisions += 16;
767 if (status & TXSTAT_BABBLED) priv->stats.tx_fifo_errors ++;
770 tx_tail = (tx_tail + 1) & 15;
771 } while (--max_work);
773 if (priv->tx_tail != tx_tail) {
774 priv->tx_tail = tx_tail;
775 netif_wake_queue(dev);
779 static void __init ether3_banner(void)
781 static unsigned version_printed = 0;
783 if (net_debug && version_printed++ == 0)
784 printk(KERN_INFO "%s", version);
787 static const char * __init
788 ether3_get_dev(struct net_device *dev, struct expansion_card *ec)
790 const char *name = "ether3";
792 dev->base_addr = ecard_address(ec, ECARD_MEMC, 0);
795 if (ec->cid.manufacturer == MANU_ANT &&
796 ec->cid.product == PROD_ANT_ETHERB) {
797 dev->base_addr += 0x200;
801 ec->irqaddr = (volatile unsigned char *)ioaddr(dev->base_addr);
804 ether3_addr(dev->dev_addr, ec);
810 ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
812 struct net_device *dev;
813 struct dev_priv *priv;
815 int i, bus_type, ret;
819 dev = init_etherdev(NULL, sizeof(struct dev_priv));
825 SET_MODULE_OWNER(dev);
827 name = ether3_get_dev(dev, ec);
834 * this will not fail - the nature of the bus ensures this
836 if (!request_region(dev->base_addr, 128, dev->name)) {
841 priv = (struct dev_priv *) dev->priv;
842 init_timer(&priv->timer);
846 ether3_outb(0x80, REG_CONFIG2 + 1);
847 bus_type = BUS_UNKNOWN;
850 /* Test using Receive Pointer (16-bit register) to find out
851 * how the ether3 is connected to the bus...
853 if (ether3_probe_bus_8(dev, 0x100) &&
854 ether3_probe_bus_8(dev, 0x201))
857 if (bus_type == BUS_UNKNOWN &&
858 ether3_probe_bus_16(dev, 0x101) &&
859 ether3_probe_bus_16(dev, 0x201))
864 printk(KERN_ERR "%s: unable to identify bus width\n", dev->name);
869 printk(KERN_ERR "%s: %s found, but is an unsupported "
870 "8-bit card\n", dev->name, name);
878 printk("%s: %s in slot %d, ", dev->name, name, ec->slot_no);
879 for (i = 0; i < 6; i++)
880 printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':');
882 if (ether3_init_2(dev)) {
887 dev->open = ether3_open;
888 dev->stop = ether3_close;
889 dev->hard_start_xmit = ether3_sendpacket;
890 dev->get_stats = ether3_getstats;
891 dev->set_multicast_list = ether3_setmulticastlist;
892 dev->tx_timeout = ether3_timeout;
893 dev->watchdog_timeo = 5 * HZ / 100;
895 ecard_set_drvdata(ec, dev);
899 release_region(dev->base_addr, 128);
901 unregister_netdev(dev);
907 static void __devexit ether3_remove(struct expansion_card *ec)
909 struct net_device *dev = ecard_get_drvdata(ec);
911 ecard_set_drvdata(ec, NULL);
913 unregister_netdev(dev);
914 release_region(dev->base_addr, 128);
918 static const struct ecard_id ether3_ids[] = {
919 { MANU_ANT2, PROD_ANT_ETHER3 },
920 { MANU_ANT, PROD_ANT_ETHER3 },
921 { MANU_ANT, PROD_ANT_ETHERB },
925 static struct ecard_driver ether3_driver = {
926 .probe = ether3_probe,
927 .remove = __devexit_p(ether3_remove),
928 .id_table = ether3_ids,
934 static int __init ether3_init(void)
936 return ecard_register_driver(ðer3_driver);
939 static void __exit ether3_exit(void)
941 ecard_remove_driver(ðer3_driver);
944 module_init(ether3_init);
945 module_exit(ether3_exit);
947 MODULE_LICENSE("GPL");