1 /* Intel EtherExpress 16 device driver for Linux
3 * Written by John Sullivan, 1995
4 * based on original code by Donald Becker, with changes by
5 * Alan Cox and Pauline Middelink.
7 * Support for 8-bit mode by Zoltan Szilagyi <zoltans@cs.arizona.edu>
9 * Many modifications, and currently maintained, by
10 * Philip Blundell <philb@gnu.org>
11 * Added the Compaq LTE Alan Cox <alan@lxorguk.ukuu.org.uk>
12 * Added MCA support Adam Fritzler (now deleted)
14 * Note - this driver is experimental still - it has problems on faster
15 * machines. Someone needs to sit down and go through it line by line with
19 /* The EtherExpress 16 is a fairly simple card, based on a shared-memory
20 * design using the i82586 Ethernet coprocessor. It bears no relationship,
21 * as far as I know, to the similarly-named "EtherExpress Pro" range.
23 * Historically, Linux support for these cards has been very bad. However,
24 * things seem to be getting better slowly.
27 /* If your card is confused about what sort of interface it has (eg it
28 * persistently reports "10baseT" when none is fitted), running 'SOFTSET /BART'
29 * or 'SOFTSET /LISA' from DOS seems to help.
32 /* Here's the scoop on memory mapping.
34 * There are three ways to access EtherExpress card memory: either using the
35 * shared-memory mapping, or using PIO through the dataport, or using PIO
36 * through the "shadow memory" ports.
38 * The shadow memory system works by having the card map some of its memory
41 * (the low five bits of the SMPTR are ignored)
43 * base+0x4000..400f memory at SMPTR+0..15
44 * base+0x8000..800f memory at SMPTR+16..31
45 * base+0xc000..c007 dubious stuff (memory at SMPTR+16..23 apparently)
46 * base+0xc008..c00f memory at 0x0008..0x000f
48 * This last set (the one at c008) is particularly handy because the SCB
49 * lives at 0x0008. So that set of ports gives us easy random access to data
50 * in the SCB without having to mess around setting up pointers and the like.
51 * We always use this method to access the SCB (via the scb_xx() functions).
53 * Dataport access works by aiming the appropriate (read or write) pointer
54 * at the first address you're interested in, and then reading or writing from
55 * the dataport. The pointers auto-increment after each transfer. We use
56 * this for data transfer.
58 * We don't use the shared-memory system because it allegedly doesn't work on
59 * all cards, and because it's a bit more prone to go wrong (it's one more
60 * thing to configure...).
65 * - The card seems to want to give us two interrupts every time something
66 * happens, where just one would be better.
71 * Note by Zoltan Szilagyi 10-12-96:
73 * I've succeeded in eliminating the "CU wedged" messages, and hence the
74 * lockups, which were only occurring with cards running in 8-bit mode ("force
75 * 8-bit operation" in Intel's SoftSet utility). This version of the driver
76 * sets the 82586 and the ASIC to 8-bit mode at startup; it also stops the
77 * CU before submitting a packet for transmission, and then restarts it as soon
78 * as the process of handing the packet is complete. This is definitely an
79 * unnecessary slowdown if the card is running in 16-bit mode; therefore one
80 * should detect 16-bit vs 8-bit mode from the EEPROM settings and act
81 * accordingly. In 8-bit mode with this bugfix I'm getting about 150 K/s for
82 * ftp's, which is significantly better than I get in DOS, so the overhead of
83 * stopping and restarting the CU with each transmit is not prohibitive in
86 * Update by David Woodhouse 11/5/99:
88 * I've seen "CU wedged" messages in 16-bit mode, on the Alpha architecture.
89 * I assume that this is because 16-bit accesses are actually handled as two
100 #include <linux/module.h>
101 #include <linux/kernel.h>
102 #include <linux/types.h>
103 #include <linux/fcntl.h>
104 #include <linux/interrupt.h>
105 #include <linux/ioport.h>
106 #include <linux/string.h>
107 #include <linux/in.h>
108 #include <linux/delay.h>
109 #include <linux/errno.h>
110 #include <linux/init.h>
111 #include <linux/netdevice.h>
112 #include <linux/etherdevice.h>
113 #include <linux/skbuff.h>
114 #include <linux/spinlock.h>
115 #include <linux/bitops.h>
116 #include <linux/jiffies.h>
125 #include "eexpress.h"
127 #define EEXP_IO_EXTENT 16
130 * Private data declarations
135 unsigned long last_tx; /* jiffies when last transmit started */
136 unsigned long init_time; /* jiffies when eexp_hw_init586 called */
137 unsigned short rx_first; /* first rx buf, same as RX_BUF_START */
138 unsigned short rx_last; /* last rx buf */
139 unsigned short rx_ptr; /* first rx buf to look at */
140 unsigned short tx_head; /* next free tx buf */
141 unsigned short tx_reap; /* first in-use tx buf */
142 unsigned short tx_tail; /* previous tx buf to tx_head */
143 unsigned short tx_link; /* last known-executing tx buf */
144 unsigned short last_tx_restart; /* set to tx_link when we
146 unsigned char started;
147 unsigned short rx_buf_start;
148 unsigned short rx_buf_end;
149 unsigned short num_tx_bufs;
150 unsigned short num_rx_bufs;
151 unsigned char width; /* 0 for 16bit, 1 for 8bit */
152 unsigned char was_promisc;
153 unsigned char old_mc_count;
157 /* This is the code and data that is downloaded to the EtherExpress card's
158 * memory at boot time.
161 static unsigned short start_code[] = {
163 0x0001, /* ISCP: busy - cleared after reset */
164 0x0008,0x0000,0x0000, /* offset,address (lo,hi) of SCB */
166 0x0000,0x0000, /* SCB: status, commands */
167 0x0000,0x0000, /* links to first command block,
168 first receive descriptor */
169 0x0000,0x0000, /* CRC error, alignment error counts */
170 0x0000,0x0000, /* out of resources, overrun error counts */
172 0x0000,0x0000, /* pad */
175 /* 0x20 -- start of 82586 CU program */
176 #define CONF_LINK 0x20
178 0x0032, /* link to next command */
179 0x080c, /* 12 bytes follow : fifo threshold=8 */
180 0x2e40, /* don't rx bad frames
181 * SRDY/ARDY => ext. sync. : preamble len=8
182 * take addresses from data buffers
185 0x6000, /* default backoff method & priority
186 * interframe spacing = 0x60 */
187 0xf200, /* slot time=0x200
188 * max collision retry = 0xf */
189 #define CONF_PROMISC 0x2e
190 0x0000, /* no HDLC : normal CRC : enable broadcast
191 * disable promiscuous/multicast modes */
192 0x003c, /* minimum frame length = 60 octets) */
195 0x003e, /* link to next command */
196 #define CONF_HWADDR 0x38
197 0x0000,0x0000,0x0000, /* hardware address placed here */
200 0x0076, /* link to next command */
201 #define CONF_NR_MULTICAST 0x44
202 0x0000, /* number of bytes in multicast address(es) */
203 #define CONF_MULTICAST 0x46
204 0x0000, 0x0000, 0x0000, /* some addresses */
205 0x0000, 0x0000, 0x0000,
206 0x0000, 0x0000, 0x0000,
207 0x0000, 0x0000, 0x0000,
208 0x0000, 0x0000, 0x0000,
209 0x0000, 0x0000, 0x0000,
210 0x0000, 0x0000, 0x0000,
211 0x0000, 0x0000, 0x0000,
213 #define CONF_DIAG_RESULT 0x76
215 0x007c, /* link to next command */
217 0x0000,Cmd_TDR|Cmd_INT,
219 #define CONF_TDR_RESULT 0x82
222 0x0000,Cmd_END|Cmd_Nop, /* end of configure sequence */
223 0x0084 /* dummy link */
226 /* maps irq number to EtherExpress magic value */
227 static char irqrmap[] = { 0,0,1,2,3,4,0,0,0,1,5,6,0,0,0,0 };
230 * Prototypes for Linux interface
233 static int eexp_open(struct net_device *dev);
234 static int eexp_close(struct net_device *dev);
235 static void eexp_timeout(struct net_device *dev);
236 static netdev_tx_t eexp_xmit(struct sk_buff *buf,
237 struct net_device *dev);
239 static irqreturn_t eexp_irq(int irq, void *dev_addr);
240 static void eexp_set_multicast(struct net_device *dev);
243 * Prototypes for hardware access functions
246 static void eexp_hw_rx_pio(struct net_device *dev);
247 static void eexp_hw_tx_pio(struct net_device *dev, unsigned short *buf,
249 static int eexp_hw_probe(struct net_device *dev,unsigned short ioaddr);
250 static unsigned short eexp_hw_readeeprom(unsigned short ioaddr,
251 unsigned char location);
253 static unsigned short eexp_hw_lasttxstat(struct net_device *dev);
254 static void eexp_hw_txrestart(struct net_device *dev);
256 static void eexp_hw_txinit (struct net_device *dev);
257 static void eexp_hw_rxinit (struct net_device *dev);
259 static void eexp_hw_init586 (struct net_device *dev);
260 static void eexp_setup_filter (struct net_device *dev);
262 static char *eexp_ifmap[]={"AUI", "BNC", "RJ45"};
263 enum eexp_iftype {AUI=0, BNC=1, TPE=2};
269 * Primitive hardware access functions.
272 static inline unsigned short scb_status(struct net_device *dev)
274 return inw(dev->base_addr + 0xc008);
277 static inline unsigned short scb_rdcmd(struct net_device *dev)
279 return inw(dev->base_addr + 0xc00a);
282 static inline void scb_command(struct net_device *dev, unsigned short cmd)
284 outw(cmd, dev->base_addr + 0xc00a);
287 static inline void scb_wrcbl(struct net_device *dev, unsigned short val)
289 outw(val, dev->base_addr + 0xc00c);
292 static inline void scb_wrrfa(struct net_device *dev, unsigned short val)
294 outw(val, dev->base_addr + 0xc00e);
297 static inline void set_loopback(struct net_device *dev)
299 outb(inb(dev->base_addr + Config) | 2, dev->base_addr + Config);
302 static inline void clear_loopback(struct net_device *dev)
304 outb(inb(dev->base_addr + Config) & ~2, dev->base_addr + Config);
307 static inline unsigned short int SHADOW(short int addr)
310 if (addr > 0xf) addr += 0x3ff0;
311 return addr + 0x4000;
319 * checks for presence of EtherExpress card
322 static int __init do_express_probe(struct net_device *dev)
324 unsigned short *port;
325 static unsigned short ports[] = { 0x240,0x300,0x310,0x270,0x320,0x340,0 };
326 unsigned short ioaddr = dev->base_addr;
327 int dev_irq = dev->irq;
330 dev->if_port = 0xff; /* not set */
333 if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress"))
335 err = eexp_hw_probe(dev,ioaddr);
336 release_region(ioaddr, EEXP_IO_EXTENT);
341 for (port=&ports[0] ; *port ; port++ )
343 unsigned short sum = 0;
345 if (!request_region(*port, EEXP_IO_EXTENT, "EtherExpress"))
347 for ( i=0 ; i<4 ; i++ )
350 t = inb(*port + ID_PORT);
351 sum |= (t>>4) << ((t & 0x03)<<2);
353 if (sum==0xbaba && !eexp_hw_probe(dev,*port)) {
354 release_region(*port, EEXP_IO_EXTENT);
357 release_region(*port, EEXP_IO_EXTENT);
364 struct net_device * __init express_probe(int unit)
366 struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
370 return ERR_PTR(-ENOMEM);
372 sprintf(dev->name, "eth%d", unit);
373 netdev_boot_setup_check(dev);
375 err = do_express_probe(dev);
384 * open and initialize the adapter, ready for use
387 static int eexp_open(struct net_device *dev)
390 unsigned short ioaddr = dev->base_addr;
391 struct net_local *lp = netdev_priv(dev);
394 printk(KERN_DEBUG "%s: eexp_open()\n", dev->name);
397 if (!dev->irq || !irqrmap[dev->irq])
400 ret = request_irq(dev->irq, eexp_irq, 0, dev->name, dev);
404 if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress")) {
405 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
409 if (!request_region(ioaddr+0x4000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
410 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
414 if (!request_region(ioaddr+0x8000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
415 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
419 if (!request_region(ioaddr+0xc000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
420 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
426 printk("%s: forcing ASIC to 8-bit mode\n", dev->name);
427 outb(inb(dev->base_addr+Config)&~4, dev->base_addr+Config);
430 eexp_hw_init586(dev);
431 netif_start_queue(dev);
433 printk(KERN_DEBUG "%s: leaving eexp_open()\n", dev->name);
438 release_region(ioaddr+0x8000, EEXP_IO_EXTENT);
440 release_region(ioaddr+0x4000, EEXP_IO_EXTENT);
442 release_region(ioaddr, EEXP_IO_EXTENT);
444 free_irq(dev->irq, dev);
449 * close and disable the interface, leaving the 586 in reset.
452 static int eexp_close(struct net_device *dev)
454 unsigned short ioaddr = dev->base_addr;
455 struct net_local *lp = netdev_priv(dev);
459 netif_stop_queue(dev);
461 outb(SIRQ_dis|irqrmap[irq],ioaddr+SET_IRQ);
463 scb_command(dev, SCB_CUsuspend|SCB_RUsuspend);
464 outb(0,ioaddr+SIGNAL_CA);
466 outb(i586_RST,ioaddr+EEPROM_Ctrl);
467 release_region(ioaddr, EEXP_IO_EXTENT);
468 release_region(ioaddr+0x4000, 16);
469 release_region(ioaddr+0x8000, 16);
470 release_region(ioaddr+0xc000, 16);
476 * This gets called when a higher level thinks we are broken. Check that
477 * nothing has become jammed in the CU.
480 static void unstick_cu(struct net_device *dev)
482 struct net_local *lp = netdev_priv(dev);
483 unsigned short ioaddr = dev->base_addr;
487 if (time_after(jiffies, dev_trans_start(dev) + HZ/2))
489 if (lp->tx_link==lp->last_tx_restart)
491 unsigned short boguscount=200,rsst;
492 printk(KERN_WARNING "%s: Retransmit timed out, status %04x, resetting...\n",
493 dev->name, scb_status(dev));
495 lp->last_tx_restart = 0;
496 scb_wrcbl(dev, lp->tx_link);
497 scb_command(dev, SCB_CUstart);
498 outb(0,ioaddr+SIGNAL_CA);
499 while (!SCB_complete(rsst=scb_status(dev)))
504 printk(KERN_WARNING "%s: Reset timed out status %04x, retrying...\n",
506 scb_wrcbl(dev, lp->tx_link);
507 scb_command(dev, SCB_CUstart);
508 outb(0,ioaddr+SIGNAL_CA);
511 netif_wake_queue(dev);
515 unsigned short status = scb_status(dev);
516 if (SCB_CUdead(status))
518 unsigned short txstatus = eexp_hw_lasttxstat(dev);
519 printk(KERN_WARNING "%s: Transmit timed out, CU not active status %04x %04x, restarting...\n",
520 dev->name, status, txstatus);
521 eexp_hw_txrestart(dev);
525 unsigned short txstatus = eexp_hw_lasttxstat(dev);
526 if (netif_queue_stopped(dev) && !txstatus)
528 printk(KERN_WARNING "%s: CU wedged, status %04x %04x, resetting...\n",
529 dev->name,status,txstatus);
530 eexp_hw_init586(dev);
531 netif_wake_queue(dev);
535 printk(KERN_WARNING "%s: transmit timed out\n", dev->name);
543 if (time_after(jiffies, lp->init_time + 10))
545 unsigned short status = scb_status(dev);
546 printk(KERN_WARNING "%s: i82586 startup timed out, status %04x, resetting...\n",
548 eexp_hw_init586(dev);
549 netif_wake_queue(dev);
554 static void eexp_timeout(struct net_device *dev)
556 struct net_local *lp = netdev_priv(dev);
562 disable_irq(dev->irq);
565 * Best would be to use synchronize_irq(); spin_lock() here
566 * lets make it work first..
570 spin_lock_irqsave(&lp->lock, flags);
573 status = scb_status(dev);
575 printk(KERN_INFO "%s: transmit timed out, %s?\n", dev->name,
576 (SCB_complete(status)?"lost interrupt":
578 dev->stats.tx_errors++;
579 lp->last_tx = jiffies;
580 if (!SCB_complete(status)) {
581 scb_command(dev, SCB_CUabort);
582 outb(0,dev->base_addr+SIGNAL_CA);
584 netif_wake_queue(dev);
586 spin_unlock_irqrestore(&lp->lock, flags);
591 * Called to transmit a packet, or to allow us to right ourselves
592 * if the kernel thinks we've died.
594 static netdev_tx_t eexp_xmit(struct sk_buff *buf, struct net_device *dev)
596 short length = buf->len;
598 struct net_local *lp = netdev_priv(dev);
603 printk(KERN_DEBUG "%s: eexp_xmit()\n", dev->name);
606 if (buf->len < ETH_ZLEN) {
607 if (skb_padto(buf, ETH_ZLEN))
612 disable_irq(dev->irq);
615 * Best would be to use synchronize_irq(); spin_lock() here
616 * lets make it work first..
620 spin_lock_irqsave(&lp->lock, flags);
624 unsigned short *data = (unsigned short *)buf->data;
626 dev->stats.tx_bytes += length;
628 eexp_hw_tx_pio(dev,data,length);
632 spin_unlock_irqrestore(&lp->lock, flags);
634 enable_irq(dev->irq);
639 * Handle an EtherExpress interrupt
640 * If we've finished initializing, start the RU and CU up.
641 * If we've already started, reap tx buffers, handle any received packets,
642 * check to make sure we've not become wedged.
645 static unsigned short eexp_start_irq(struct net_device *dev,
646 unsigned short status)
648 unsigned short ack_cmd = SCB_ack(status);
649 struct net_local *lp = netdev_priv(dev);
650 unsigned short ioaddr = dev->base_addr;
651 if ((dev->flags & IFF_UP) && !(lp->started & STARTED_CU)) {
652 short diag_status, tdr_status;
653 while (SCB_CUstat(status)==2)
654 status = scb_status(dev);
656 printk("%s: CU went non-active (status %04x)\n",
660 outw(CONF_DIAG_RESULT & ~31, ioaddr + SM_PTR);
661 diag_status = inw(ioaddr + SHADOW(CONF_DIAG_RESULT));
662 if (diag_status & 1<<11) {
663 printk(KERN_WARNING "%s: 82586 failed self-test\n",
665 } else if (!(diag_status & 1<<13)) {
666 printk(KERN_WARNING "%s: 82586 self-test failed to complete\n", dev->name);
669 outw(CONF_TDR_RESULT & ~31, ioaddr + SM_PTR);
670 tdr_status = inw(ioaddr + SHADOW(CONF_TDR_RESULT));
671 if (tdr_status & (TDR_SHORT|TDR_OPEN)) {
672 printk(KERN_WARNING "%s: TDR reports cable %s at %d tick%s\n", dev->name, (tdr_status & TDR_SHORT)?"short":"broken", tdr_status & TDR_TIME, ((tdr_status & TDR_TIME) != 1) ? "s" : "");
674 else if (tdr_status & TDR_XCVRPROBLEM) {
675 printk(KERN_WARNING "%s: TDR reports transceiver problem\n", dev->name);
677 else if (tdr_status & TDR_LINKOK) {
679 printk(KERN_DEBUG "%s: TDR reports link OK\n", dev->name);
682 printk("%s: TDR is ga-ga (status %04x)\n", dev->name,
686 lp->started |= STARTED_CU;
687 scb_wrcbl(dev, lp->tx_link);
688 /* if the RU isn't running, start it now */
689 if (!(lp->started & STARTED_RU)) {
690 ack_cmd |= SCB_RUstart;
691 scb_wrrfa(dev, lp->rx_buf_start);
692 lp->rx_ptr = lp->rx_buf_start;
693 lp->started |= STARTED_RU;
695 ack_cmd |= SCB_CUstart | 0x2000;
698 if ((dev->flags & IFF_UP) && !(lp->started & STARTED_RU) && SCB_RUstat(status)==4)
699 lp->started|=STARTED_RU;
704 static void eexp_cmd_clear(struct net_device *dev)
706 unsigned long int oldtime = jiffies;
707 while (scb_rdcmd(dev) && (time_before(jiffies, oldtime + 10)));
708 if (scb_rdcmd(dev)) {
709 printk("%s: command didn't clear\n", dev->name);
713 static irqreturn_t eexp_irq(int dummy, void *dev_info)
715 struct net_device *dev = dev_info;
716 struct net_local *lp;
717 unsigned short ioaddr,status,ack_cmd;
718 unsigned short old_read_ptr, old_write_ptr;
720 lp = netdev_priv(dev);
721 ioaddr = dev->base_addr;
723 spin_lock(&lp->lock);
725 old_read_ptr = inw(ioaddr+READ_PTR);
726 old_write_ptr = inw(ioaddr+WRITE_PTR);
728 outb(SIRQ_dis|irqrmap[dev->irq], ioaddr+SET_IRQ);
730 status = scb_status(dev);
733 printk(KERN_DEBUG "%s: interrupt (status %x)\n", dev->name, status);
736 if (lp->started == (STARTED_CU | STARTED_RU)) {
741 ack_cmd = SCB_ack(status);
742 scb_command(dev, ack_cmd);
743 outb(0,ioaddr+SIGNAL_CA);
747 if (SCB_complete(status)) {
748 if (!eexp_hw_lasttxstat(dev)) {
749 printk("%s: tx interrupt but no status\n", dev->name);
753 if (SCB_rxdframe(status))
756 status = scb_status(dev);
757 } while (status & 0xc000);
759 if (SCB_RUdead(status))
761 printk(KERN_WARNING "%s: RU stopped: status %04x\n",
764 printk(KERN_WARNING "%s: cur_rfd=%04x, cur_rbd=%04x\n", dev->name, lp->cur_rfd, lp->cur_rbd);
765 outw(lp->cur_rfd, ioaddr+READ_PTR);
766 printk(KERN_WARNING "%s: [%04x]\n", dev->name, inw(ioaddr+DATAPORT));
767 outw(lp->cur_rfd+6, ioaddr+READ_PTR);
768 printk(KERN_WARNING "%s: rbd is %04x\n", dev->name, rbd= inw(ioaddr+DATAPORT));
769 outw(rbd, ioaddr+READ_PTR);
770 printk(KERN_WARNING "%s: [%04x %04x] ", dev->name, inw(ioaddr+DATAPORT), inw(ioaddr+DATAPORT));
771 outw(rbd+8, ioaddr+READ_PTR);
772 printk("[%04x]\n", inw(ioaddr+DATAPORT));
774 dev->stats.rx_errors++;
778 lp->cur_rfd = lp->first_rfd;
780 scb_wrrfa(dev, lp->rx_buf_start);
781 scb_command(dev, SCB_RUstart);
782 outb(0,ioaddr+SIGNAL_CA);
786 ack_cmd = eexp_start_irq(dev, status);
788 ack_cmd = SCB_ack(status);
789 scb_command(dev, ack_cmd);
790 outb(0,ioaddr+SIGNAL_CA);
795 outb(SIRQ_en|irqrmap[dev->irq], ioaddr+SET_IRQ);
798 printk("%s: leaving eexp_irq()\n", dev->name);
800 outw(old_read_ptr, ioaddr+READ_PTR);
801 outw(old_write_ptr, ioaddr+WRITE_PTR);
803 spin_unlock(&lp->lock);
808 * Hardware access functions
812 * Set the cable type to use.
815 static void eexp_hw_set_interface(struct net_device *dev)
817 unsigned char oldval = inb(dev->base_addr + 0x300e);
819 switch (dev->if_port) {
826 outb(oldval, dev->base_addr+0x300e);
831 * Check all the receive buffers, and hand any received packets
832 * to the upper levels. Basic sanity check on each frame
833 * descriptor, though we don't bother trying to fix broken ones.
836 static void eexp_hw_rx_pio(struct net_device *dev)
838 struct net_local *lp = netdev_priv(dev);
839 unsigned short rx_block = lp->rx_ptr;
840 unsigned short boguscount = lp->num_rx_bufs;
841 unsigned short ioaddr = dev->base_addr;
842 unsigned short status;
845 printk(KERN_DEBUG "%s: eexp_hw_rx()\n", dev->name);
849 unsigned short rfd_cmd, rx_next, pbuf, pkt_len;
851 outw(rx_block, ioaddr + READ_PTR);
852 status = inw(ioaddr + DATAPORT);
856 rfd_cmd = inw(ioaddr + DATAPORT);
857 rx_next = inw(ioaddr + DATAPORT);
858 pbuf = inw(ioaddr + DATAPORT);
860 outw(pbuf, ioaddr + READ_PTR);
861 pkt_len = inw(ioaddr + DATAPORT);
865 printk(KERN_WARNING "%s: rfd_cmd not zero:0x%04x\n",
869 else if (pbuf!=rx_block+0x16)
871 printk(KERN_WARNING "%s: rfd and rbd out of sync 0x%04x 0x%04x\n",
872 dev->name, rx_block+0x16, pbuf);
875 else if ((pkt_len & 0xc000)!=0xc000)
877 printk(KERN_WARNING "%s: EOF or F not set on received buffer (%04x)\n",
878 dev->name, pkt_len & 0xc000);
881 else if (!FD_OK(status))
883 dev->stats.rx_errors++;
885 dev->stats.rx_crc_errors++;
886 if (FD_Align(status))
887 dev->stats.rx_frame_errors++;
888 if (FD_Resrc(status))
889 dev->stats.rx_fifo_errors++;
891 dev->stats.rx_over_errors++;
892 if (FD_Short(status))
893 dev->stats.rx_length_errors++;
899 skb = netdev_alloc_skb(dev, pkt_len + 16);
902 printk(KERN_WARNING "%s: Memory squeeze, dropping packet\n",dev->name);
903 dev->stats.rx_dropped++;
907 outw(pbuf+10, ioaddr+READ_PTR);
908 insw(ioaddr+DATAPORT, skb_put(skb,pkt_len),(pkt_len+1)>>1);
909 skb->protocol = eth_type_trans(skb,dev);
911 dev->stats.rx_packets++;
912 dev->stats.rx_bytes += pkt_len;
914 outw(rx_block, ioaddr+WRITE_PTR);
915 outw(0, ioaddr+DATAPORT);
916 outw(0, ioaddr+DATAPORT);
919 } while (FD_Done(status) && boguscount--);
920 lp->rx_ptr = rx_block;
924 * Hand a packet to the card for transmission
925 * If we get here, we MUST have already checked
926 * to make sure there is room in the transmit
930 static void eexp_hw_tx_pio(struct net_device *dev, unsigned short *buf,
933 struct net_local *lp = netdev_priv(dev);
934 unsigned short ioaddr = dev->base_addr;
936 if (LOCKUP16 || lp->width) {
937 /* Stop the CU so that there is no chance that it
938 jumps off to a bogus address while we are writing the
939 pointer to the next transmit packet in 8-bit mode --
940 this eliminates the "CU wedged" errors in 8-bit mode.
941 (Zoltan Szilagyi 10-12-96) */
942 scb_command(dev, SCB_CUsuspend);
943 outw(0xFFFF, ioaddr+SIGNAL_CA);
946 outw(lp->tx_head, ioaddr + WRITE_PTR);
948 outw(0x0000, ioaddr + DATAPORT);
949 outw(Cmd_INT|Cmd_Xmit, ioaddr + DATAPORT);
950 outw(lp->tx_head+0x08, ioaddr + DATAPORT);
951 outw(lp->tx_head+0x0e, ioaddr + DATAPORT);
953 outw(0x0000, ioaddr + DATAPORT);
954 outw(0x0000, ioaddr + DATAPORT);
955 outw(lp->tx_head+0x08, ioaddr + DATAPORT);
957 outw(0x8000|len, ioaddr + DATAPORT);
958 outw(-1, ioaddr + DATAPORT);
959 outw(lp->tx_head+0x16, ioaddr + DATAPORT);
960 outw(0, ioaddr + DATAPORT);
962 outsw(ioaddr + DATAPORT, buf, (len+1)>>1);
964 outw(lp->tx_tail+0xc, ioaddr + WRITE_PTR);
965 outw(lp->tx_head, ioaddr + DATAPORT);
967 dev->trans_start = jiffies;
968 lp->tx_tail = lp->tx_head;
969 if (lp->tx_head==TX_BUF_START+((lp->num_tx_bufs-1)*TX_BUF_SIZE))
970 lp->tx_head = TX_BUF_START;
972 lp->tx_head += TX_BUF_SIZE;
973 if (lp->tx_head != lp->tx_reap)
974 netif_wake_queue(dev);
976 if (LOCKUP16 || lp->width) {
977 /* Restart the CU so that the packet can actually
978 be transmitted. (Zoltan Szilagyi 10-12-96) */
979 scb_command(dev, SCB_CUresume);
980 outw(0xFFFF, ioaddr+SIGNAL_CA);
983 dev->stats.tx_packets++;
984 lp->last_tx = jiffies;
987 static const struct net_device_ops eexp_netdev_ops = {
988 .ndo_open = eexp_open,
989 .ndo_stop = eexp_close,
990 .ndo_start_xmit = eexp_xmit,
991 .ndo_set_rx_mode = eexp_set_multicast,
992 .ndo_tx_timeout = eexp_timeout,
993 .ndo_change_mtu = eth_change_mtu,
994 .ndo_set_mac_address = eth_mac_addr,
995 .ndo_validate_addr = eth_validate_addr,
999 * Sanity check the suspected EtherExpress card
1000 * Read hardware address, reset card, size memory and initialize buffer
1001 * memory pointers. These are held in netdev_priv(), in case someone has more
1002 * than one card in a machine.
1005 static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
1007 unsigned short hw_addr[3];
1008 unsigned char buswidth;
1009 unsigned int memory_size;
1011 unsigned short xsum = 0;
1012 struct net_local *lp = netdev_priv(dev);
1014 printk("%s: EtherExpress 16 at %#x ",dev->name,ioaddr);
1016 outb(ASIC_RST, ioaddr+EEPROM_Ctrl);
1017 outb(0, ioaddr+EEPROM_Ctrl);
1019 outb(i586_RST, ioaddr+EEPROM_Ctrl);
1021 hw_addr[0] = eexp_hw_readeeprom(ioaddr,2);
1022 hw_addr[1] = eexp_hw_readeeprom(ioaddr,3);
1023 hw_addr[2] = eexp_hw_readeeprom(ioaddr,4);
1025 /* Standard Address or Compaq LTE Address */
1026 if (!((hw_addr[2]==0x00aa && ((hw_addr[1] & 0xff00)==0x0000)) ||
1027 (hw_addr[2]==0x0080 && ((hw_addr[1] & 0xff00)==0x5F00))))
1029 printk(" rejected: invalid address %04x%04x%04x\n",
1030 hw_addr[2],hw_addr[1],hw_addr[0]);
1034 /* Calculate the EEPROM checksum. Carry on anyway if it's bad,
1037 for (i = 0; i < 64; i++)
1038 xsum += eexp_hw_readeeprom(ioaddr, i);
1040 printk(" (bad EEPROM xsum 0x%02x)", xsum);
1042 dev->base_addr = ioaddr;
1043 for ( i=0 ; i<6 ; i++ )
1044 dev->dev_addr[i] = ((unsigned char *)hw_addr)[5-i];
1047 static const char irqmap[] = { 0, 9, 3, 4, 5, 10, 11, 0 };
1048 unsigned short setupval = eexp_hw_readeeprom(ioaddr,0);
1050 /* Use the IRQ from EEPROM if none was given */
1052 dev->irq = irqmap[setupval>>13];
1054 if (dev->if_port == 0xff) {
1055 dev->if_port = !(setupval & 0x1000) ? AUI :
1056 eexp_hw_readeeprom(ioaddr,5) & 0x1 ? TPE : BNC;
1059 buswidth = !((setupval & 0x400) >> 10);
1062 memset(lp, 0, sizeof(struct net_local));
1063 spin_lock_init(&lp->lock);
1065 printk("(IRQ %d, %s connector, %d-bit bus", dev->irq,
1066 eexp_ifmap[dev->if_port], buswidth?8:16);
1068 if (!request_region(dev->base_addr + 0x300e, 1, "EtherExpress"))
1071 eexp_hw_set_interface(dev);
1073 release_region(dev->base_addr + 0x300e, 1);
1075 /* Find out how much RAM we have on the card */
1076 outw(0, dev->base_addr + WRITE_PTR);
1077 for (i = 0; i < 32768; i++)
1078 outw(0, dev->base_addr + DATAPORT);
1080 for (memory_size = 0; memory_size < 64; memory_size++)
1082 outw(memory_size<<10, dev->base_addr + READ_PTR);
1083 if (inw(dev->base_addr+DATAPORT))
1085 outw(memory_size<<10, dev->base_addr + WRITE_PTR);
1086 outw(memory_size | 0x5000, dev->base_addr+DATAPORT);
1087 outw(memory_size<<10, dev->base_addr + READ_PTR);
1088 if (inw(dev->base_addr+DATAPORT) != (memory_size | 0x5000))
1092 /* Sort out the number of buffers. We may have 16, 32, 48 or 64k
1093 * of RAM to play with.
1095 lp->num_tx_bufs = 4;
1096 lp->rx_buf_end = 0x3ff6;
1097 switch (memory_size)
1100 lp->rx_buf_end += 0x4000;
1102 lp->num_tx_bufs += 4;
1103 lp->rx_buf_end += 0x4000;
1105 lp->rx_buf_end += 0x4000;
1107 printk(", %dk RAM)\n", memory_size);
1110 printk(") bad memory size (%dk).\n", memory_size);
1115 lp->rx_buf_start = TX_BUF_START + (lp->num_tx_bufs*TX_BUF_SIZE);
1116 lp->width = buswidth;
1118 dev->netdev_ops = &eexp_netdev_ops;
1119 dev->watchdog_timeo = 2*HZ;
1121 return register_netdev(dev);
1125 * Read a word from the EtherExpress on-board serial EEPROM.
1126 * The EEPROM contains 64 words of 16 bits.
1128 static unsigned short __init eexp_hw_readeeprom(unsigned short ioaddr,
1129 unsigned char location)
1131 unsigned short cmd = 0x180|(location&0x7f);
1132 unsigned short rval = 0,wval = EC_CS|i586_RST;
1135 outb(EC_CS|i586_RST,ioaddr+EEPROM_Ctrl);
1136 for (i=0x100 ; i ; i>>=1 )
1143 outb(wval,ioaddr+EEPROM_Ctrl);
1144 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1146 outb(wval,ioaddr+EEPROM_Ctrl);
1150 outb(wval,ioaddr+EEPROM_Ctrl);
1151 for (i=0x8000 ; i ; i>>=1 )
1153 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1155 if (inb(ioaddr+EEPROM_Ctrl)&EC_Rd)
1157 outb(wval,ioaddr+EEPROM_Ctrl);
1161 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1163 outb(wval,ioaddr+EEPROM_Ctrl);
1169 * Reap tx buffers and return last transmit status.
1170 * if ==0 then either:
1171 * a) we're not transmitting anything, so why are we here?
1173 * otherwise, Stat_Busy(return) means we've still got some packets
1174 * to transmit, Stat_Done(return) means our buffers should be empty
1178 static unsigned short eexp_hw_lasttxstat(struct net_device *dev)
1180 struct net_local *lp = netdev_priv(dev);
1181 unsigned short tx_block = lp->tx_reap;
1182 unsigned short status;
1184 if (!netif_queue_stopped(dev) && lp->tx_head==lp->tx_reap)
1189 outw(tx_block & ~31, dev->base_addr + SM_PTR);
1190 status = inw(dev->base_addr + SHADOW(tx_block));
1191 if (!Stat_Done(status))
1193 lp->tx_link = tx_block;
1198 lp->last_tx_restart = 0;
1199 dev->stats.collisions += Stat_NoColl(status);
1200 if (!Stat_OK(status))
1202 char *whatsup = NULL;
1203 dev->stats.tx_errors++;
1204 if (Stat_Abort(status))
1205 dev->stats.tx_aborted_errors++;
1206 if (Stat_TNoCar(status)) {
1207 whatsup = "aborted, no carrier";
1208 dev->stats.tx_carrier_errors++;
1210 if (Stat_TNoCTS(status)) {
1211 whatsup = "aborted, lost CTS";
1212 dev->stats.tx_carrier_errors++;
1214 if (Stat_TNoDMA(status)) {
1215 whatsup = "FIFO underran";
1216 dev->stats.tx_fifo_errors++;
1218 if (Stat_TXColl(status)) {
1219 whatsup = "aborted, too many collisions";
1220 dev->stats.tx_aborted_errors++;
1223 printk(KERN_INFO "%s: transmit %s\n",
1224 dev->name, whatsup);
1227 dev->stats.tx_packets++;
1229 if (tx_block == TX_BUF_START+((lp->num_tx_bufs-1)*TX_BUF_SIZE))
1230 lp->tx_reap = tx_block = TX_BUF_START;
1232 lp->tx_reap = tx_block += TX_BUF_SIZE;
1233 netif_wake_queue(dev);
1235 while (lp->tx_reap != lp->tx_head);
1237 lp->tx_link = lp->tx_tail + 0x08;
1243 * This should never happen. It is called when some higher routine detects
1244 * that the CU has stopped, to try to restart it from the last packet we knew
1245 * we were working on, or the idle loop if we had finished for the time.
1248 static void eexp_hw_txrestart(struct net_device *dev)
1250 struct net_local *lp = netdev_priv(dev);
1251 unsigned short ioaddr = dev->base_addr;
1253 lp->last_tx_restart = lp->tx_link;
1254 scb_wrcbl(dev, lp->tx_link);
1255 scb_command(dev, SCB_CUstart);
1256 outb(0,ioaddr+SIGNAL_CA);
1259 unsigned short boguscount=50,failcount=5;
1260 while (!scb_status(dev))
1266 printk(KERN_WARNING "%s: CU start timed out, status %04x, cmd %04x\n", dev->name, scb_status(dev), scb_rdcmd(dev));
1267 scb_wrcbl(dev, lp->tx_link);
1268 scb_command(dev, SCB_CUstart);
1269 outb(0,ioaddr+SIGNAL_CA);
1274 printk(KERN_WARNING "%s: Failed to restart CU, resetting board...\n",dev->name);
1275 eexp_hw_init586(dev);
1276 netif_wake_queue(dev);
1285 * Writes down the list of transmit buffers into card memory. Each
1286 * entry consists of an 82586 transmit command, followed by a jump
1287 * pointing to itself. When we want to transmit a packet, we write
1288 * the data into the appropriate transmit buffer and then modify the
1289 * preceding jump to point at the new transmit command. This means that
1290 * the 586 command unit is continuously active.
1293 static void eexp_hw_txinit(struct net_device *dev)
1295 struct net_local *lp = netdev_priv(dev);
1296 unsigned short tx_block = TX_BUF_START;
1297 unsigned short curtbuf;
1298 unsigned short ioaddr = dev->base_addr;
1300 for ( curtbuf=0 ; curtbuf<lp->num_tx_bufs ; curtbuf++ )
1302 outw(tx_block, ioaddr + WRITE_PTR);
1304 outw(0x0000, ioaddr + DATAPORT);
1305 outw(Cmd_INT|Cmd_Xmit, ioaddr + DATAPORT);
1306 outw(tx_block+0x08, ioaddr + DATAPORT);
1307 outw(tx_block+0x0e, ioaddr + DATAPORT);
1309 outw(0x0000, ioaddr + DATAPORT);
1310 outw(0x0000, ioaddr + DATAPORT);
1311 outw(tx_block+0x08, ioaddr + DATAPORT);
1313 outw(0x8000, ioaddr + DATAPORT);
1314 outw(-1, ioaddr + DATAPORT);
1315 outw(tx_block+0x16, ioaddr + DATAPORT);
1316 outw(0x0000, ioaddr + DATAPORT);
1318 tx_block += TX_BUF_SIZE;
1320 lp->tx_head = TX_BUF_START;
1321 lp->tx_reap = TX_BUF_START;
1322 lp->tx_tail = tx_block - TX_BUF_SIZE;
1323 lp->tx_link = lp->tx_tail + 0x08;
1324 lp->rx_buf_start = tx_block;
1329 * Write the circular list of receive buffer descriptors to card memory.
1330 * The end of the list isn't marked, which means that the 82586 receive
1331 * unit will loop until buffers become available (this avoids it giving us
1332 * "out of resources" messages).
1335 static void eexp_hw_rxinit(struct net_device *dev)
1337 struct net_local *lp = netdev_priv(dev);
1338 unsigned short rx_block = lp->rx_buf_start;
1339 unsigned short ioaddr = dev->base_addr;
1341 lp->num_rx_bufs = 0;
1342 lp->rx_first = lp->rx_ptr = rx_block;
1347 outw(rx_block, ioaddr + WRITE_PTR);
1349 outw(0, ioaddr + DATAPORT); outw(0, ioaddr+DATAPORT);
1350 outw(rx_block + RX_BUF_SIZE, ioaddr+DATAPORT);
1351 outw(0xffff, ioaddr+DATAPORT);
1353 outw(0x0000, ioaddr+DATAPORT);
1354 outw(0xdead, ioaddr+DATAPORT);
1355 outw(0xdead, ioaddr+DATAPORT);
1356 outw(0xdead, ioaddr+DATAPORT);
1357 outw(0xdead, ioaddr+DATAPORT);
1358 outw(0xdead, ioaddr+DATAPORT);
1359 outw(0xdead, ioaddr+DATAPORT);
1361 outw(0x0000, ioaddr+DATAPORT);
1362 outw(rx_block + RX_BUF_SIZE + 0x16, ioaddr+DATAPORT);
1363 outw(rx_block + 0x20, ioaddr+DATAPORT);
1364 outw(0, ioaddr+DATAPORT);
1365 outw(RX_BUF_SIZE-0x20, ioaddr+DATAPORT);
1367 lp->rx_last = rx_block;
1368 rx_block += RX_BUF_SIZE;
1369 } while (rx_block <= lp->rx_buf_end-RX_BUF_SIZE);
1372 /* Make first Rx frame descriptor point to first Rx buffer
1374 outw(lp->rx_first + 6, ioaddr+WRITE_PTR);
1375 outw(lp->rx_first + 0x16, ioaddr+DATAPORT);
1377 /* Close Rx frame descriptor ring */
1378 outw(lp->rx_last + 4, ioaddr+WRITE_PTR);
1379 outw(lp->rx_first, ioaddr+DATAPORT);
1381 /* Close Rx buffer descriptor ring */
1382 outw(lp->rx_last + 0x16 + 2, ioaddr+WRITE_PTR);
1383 outw(lp->rx_first + 0x16, ioaddr+DATAPORT);
1388 * Un-reset the 586, and start the configuration sequence. We don't wait for
1389 * this to finish, but allow the interrupt handler to start the CU and RU for
1390 * us. We can't start the receive/transmission system up before we know that
1391 * the hardware is configured correctly.
1394 static void eexp_hw_init586(struct net_device *dev)
1396 struct net_local *lp = netdev_priv(dev);
1397 unsigned short ioaddr = dev->base_addr;
1401 printk("%s: eexp_hw_init586()\n", dev->name);
1408 outb(SIRQ_dis|irqrmap[dev->irq],ioaddr+SET_IRQ);
1410 /* Download the startup code */
1411 outw(lp->rx_buf_end & ~31, ioaddr + SM_PTR);
1412 outw(lp->width?0x0001:0x0000, ioaddr + 0x8006);
1413 outw(0x0000, ioaddr + 0x8008);
1414 outw(0x0000, ioaddr + 0x800a);
1415 outw(0x0000, ioaddr + 0x800c);
1416 outw(0x0000, ioaddr + 0x800e);
1418 for (i = 0; i < ARRAY_SIZE(start_code) * 2; i+=32) {
1420 outw(i, ioaddr + SM_PTR);
1421 for (j = 0; j < 16 && (i+j)/2 < ARRAY_SIZE(start_code); j+=2)
1422 outw(start_code[(i+j)/2],
1424 for (j = 0; j < 16 && (i+j+16)/2 < ARRAY_SIZE(start_code); j+=2)
1425 outw(start_code[(i+j+16)/2],
1429 /* Do we want promiscuous mode or multicast? */
1430 outw(CONF_PROMISC & ~31, ioaddr+SM_PTR);
1431 i = inw(ioaddr+SHADOW(CONF_PROMISC));
1432 outw((dev->flags & IFF_PROMISC)?(i|1):(i & ~1),
1433 ioaddr+SHADOW(CONF_PROMISC));
1434 lp->was_promisc = dev->flags & IFF_PROMISC;
1436 eexp_setup_filter(dev);
1439 /* Write our hardware address */
1440 outw(CONF_HWADDR & ~31, ioaddr+SM_PTR);
1441 outw(((unsigned short *)dev->dev_addr)[0], ioaddr+SHADOW(CONF_HWADDR));
1442 outw(((unsigned short *)dev->dev_addr)[1],
1443 ioaddr+SHADOW(CONF_HWADDR+2));
1444 outw(((unsigned short *)dev->dev_addr)[2],
1445 ioaddr+SHADOW(CONF_HWADDR+4));
1447 eexp_hw_txinit(dev);
1448 eexp_hw_rxinit(dev);
1450 outb(0,ioaddr+EEPROM_Ctrl);
1453 scb_command(dev, 0xf000);
1454 outb(0,ioaddr+SIGNAL_CA);
1456 outw(0, ioaddr+SM_PTR);
1459 unsigned short rboguscount=50,rfailcount=5;
1460 while (inw(ioaddr+0x4000))
1464 printk(KERN_WARNING "%s: i82586 reset timed out, kicking...\n",
1466 scb_command(dev, 0);
1467 outb(0,ioaddr+SIGNAL_CA);
1471 printk(KERN_WARNING "%s: i82586 not responding, giving up.\n",
1479 scb_wrcbl(dev, CONF_LINK);
1480 scb_command(dev, 0xf000|SCB_CUstart);
1481 outb(0,ioaddr+SIGNAL_CA);
1484 unsigned short iboguscount=50,ifailcount=5;
1485 while (!scb_status(dev))
1491 printk(KERN_WARNING "%s: i82586 initialization timed out, status %04x, cmd %04x\n",
1492 dev->name, scb_status(dev), scb_rdcmd(dev));
1493 scb_wrcbl(dev, CONF_LINK);
1494 scb_command(dev, 0xf000|SCB_CUstart);
1495 outb(0,ioaddr+SIGNAL_CA);
1500 printk(KERN_WARNING "%s: Failed to initialize i82586, giving up.\n",dev->name);
1507 clear_loopback(dev);
1508 outb(SIRQ_en|irqrmap[dev->irq],ioaddr+SET_IRQ);
1510 lp->init_time = jiffies;
1512 printk("%s: leaving eexp_hw_init586()\n", dev->name);
1516 static void eexp_setup_filter(struct net_device *dev)
1518 struct netdev_hw_addr *ha;
1519 unsigned short ioaddr = dev->base_addr;
1520 int count = netdev_mc_count(dev);
1523 printk(KERN_INFO "%s: too many multicast addresses (%d)\n",
1528 outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR);
1529 outw(6*count, ioaddr+SHADOW(CONF_NR_MULTICAST));
1531 netdev_for_each_mc_addr(ha, dev) {
1532 unsigned short *data = (unsigned short *) ha->addr;
1536 outw((CONF_MULTICAST+(6*i)) & ~31, ioaddr+SM_PTR);
1537 outw(data[0], ioaddr+SHADOW(CONF_MULTICAST+(6*i)));
1538 outw((CONF_MULTICAST+(6*i)+2) & ~31, ioaddr+SM_PTR);
1539 outw(data[1], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+2));
1540 outw((CONF_MULTICAST+(6*i)+4) & ~31, ioaddr+SM_PTR);
1541 outw(data[2], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+4));
1547 * Set or clear the multicast filter for this adaptor.
1550 eexp_set_multicast(struct net_device *dev)
1552 unsigned short ioaddr = dev->base_addr;
1553 struct net_local *lp = netdev_priv(dev);
1555 if ((dev->flags & IFF_PROMISC) != lp->was_promisc) {
1556 outw(CONF_PROMISC & ~31, ioaddr+SM_PTR);
1557 i = inw(ioaddr+SHADOW(CONF_PROMISC));
1558 outw((dev->flags & IFF_PROMISC)?(i|1):(i & ~1),
1559 ioaddr+SHADOW(CONF_PROMISC));
1560 lp->was_promisc = dev->flags & IFF_PROMISC;
1563 if (!(dev->flags & IFF_PROMISC)) {
1564 eexp_setup_filter(dev);
1565 if (lp->old_mc_count != netdev_mc_count(dev)) {
1567 lp->old_mc_count = netdev_mc_count(dev);
1572 scb_command(dev, SCB_CUsuspend);
1573 outb(0, ioaddr+SIGNAL_CA);
1574 outb(0, ioaddr+SIGNAL_CA);
1576 printk("%s: waiting for CU to go suspended\n", dev->name);
1579 while ((SCB_CUstat(scb_status(dev)) == 2) &&
1580 (time_before(jiffies, oj + 2000)));
1581 if (SCB_CUstat(scb_status(dev)) == 2)
1582 printk("%s: warning, CU didn't stop\n", dev->name);
1583 lp->started &= ~(STARTED_CU);
1584 scb_wrcbl(dev, CONF_LINK);
1585 scb_command(dev, SCB_CUstart);
1586 outb(0, ioaddr+SIGNAL_CA);
1597 #define EEXP_MAX_CARDS 4 /* max number of cards to support */
1599 static struct net_device *dev_eexp[EEXP_MAX_CARDS];
1600 static int irq[EEXP_MAX_CARDS];
1601 static int io[EEXP_MAX_CARDS];
1603 module_param_array(io, int, NULL, 0);
1604 module_param_array(irq, int, NULL, 0);
1605 MODULE_PARM_DESC(io, "EtherExpress 16 I/O base address(es)");
1606 MODULE_PARM_DESC(irq, "EtherExpress 16 IRQ number(s)");
1607 MODULE_LICENSE("GPL");
1610 /* Ideally the user would give us io=, irq= for every card. If any parameters
1611 * are specified, we verify and then use them. If no parameters are given, we
1612 * autoprobe for one card only.
1614 int __init init_module(void)
1616 struct net_device *dev;
1617 int this_dev, found = 0;
1619 for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
1620 dev = alloc_etherdev(sizeof(struct net_local));
1621 dev->irq = irq[this_dev];
1622 dev->base_addr = io[this_dev];
1623 if (io[this_dev] == 0) {
1626 printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n");
1628 if (do_express_probe(dev) == 0) {
1629 dev_eexp[this_dev] = dev;
1633 printk(KERN_WARNING "eexpress.c: Failed to register card at 0x%x.\n", io[this_dev]);
1642 void __exit cleanup_module(void)
1646 for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
1647 struct net_device *dev = dev_eexp[this_dev];
1649 unregister_netdev(dev);
1658 * c-file-style: "linux"