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 <Philip.Blundell@pobox.com>
11 * Added the Compaq LTE Alan Cox <alan@redhat.com>
12 * Added MCA support Adam Fritzler <mid@auk.cx>
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/config.h>
101 #include <linux/module.h>
102 #include <linux/kernel.h>
103 #include <linux/types.h>
104 #include <linux/fcntl.h>
105 #include <linux/interrupt.h>
106 #include <linux/ioport.h>
107 #include <linux/string.h>
108 #include <linux/in.h>
109 #include <linux/delay.h>
110 #include <linux/errno.h>
111 #include <linux/init.h>
112 #include <linux/netdevice.h>
113 #include <linux/etherdevice.h>
114 #include <linux/skbuff.h>
115 #include <linux/slab.h>
116 #include <linux/mca-legacy.h>
117 #include <linux/spinlock.h>
119 #include <asm/system.h>
120 #include <asm/bitops.h>
128 #include "eexpress.h"
130 #define EEXP_IO_EXTENT 16
133 * Private data declarations
138 struct net_device_stats stats;
139 unsigned long last_tx; /* jiffies when last transmit started */
140 unsigned long init_time; /* jiffies when eexp_hw_init586 called */
141 unsigned short rx_first; /* first rx buf, same as RX_BUF_START */
142 unsigned short rx_last; /* last rx buf */
143 unsigned short rx_ptr; /* first rx buf to look at */
144 unsigned short tx_head; /* next free tx buf */
145 unsigned short tx_reap; /* first in-use tx buf */
146 unsigned short tx_tail; /* previous tx buf to tx_head */
147 unsigned short tx_link; /* last known-executing tx buf */
148 unsigned short last_tx_restart; /* set to tx_link when we
150 unsigned char started;
151 unsigned short rx_buf_start;
152 unsigned short rx_buf_end;
153 unsigned short num_tx_bufs;
154 unsigned short num_rx_bufs;
155 unsigned char width; /* 0 for 16bit, 1 for 8bit */
156 unsigned char was_promisc;
157 unsigned char old_mc_count;
161 /* This is the code and data that is downloaded to the EtherExpress card's
162 * memory at boot time.
165 static unsigned short start_code[] = {
167 0x0001, /* ISCP: busy - cleared after reset */
168 0x0008,0x0000,0x0000, /* offset,address (lo,hi) of SCB */
170 0x0000,0x0000, /* SCB: status, commands */
171 0x0000,0x0000, /* links to first command block,
172 first receive descriptor */
173 0x0000,0x0000, /* CRC error, alignment error counts */
174 0x0000,0x0000, /* out of resources, overrun error counts */
176 0x0000,0x0000, /* pad */
179 /* 0x20 -- start of 82586 CU program */
180 #define CONF_LINK 0x20
182 0x0032, /* link to next command */
183 0x080c, /* 12 bytes follow : fifo threshold=8 */
184 0x2e40, /* don't rx bad frames
185 * SRDY/ARDY => ext. sync. : preamble len=8
186 * take addresses from data buffers
189 0x6000, /* default backoff method & priority
190 * interframe spacing = 0x60 */
191 0xf200, /* slot time=0x200
192 * max collision retry = 0xf */
193 #define CONF_PROMISC 0x2e
194 0x0000, /* no HDLC : normal CRC : enable broadcast
195 * disable promiscuous/multicast modes */
196 0x003c, /* minimum frame length = 60 octets) */
199 0x003e, /* link to next command */
200 #define CONF_HWADDR 0x38
201 0x0000,0x0000,0x0000, /* hardware address placed here */
204 0x0076, /* link to next command */
205 #define CONF_NR_MULTICAST 0x44
206 0x0000, /* number of multicast addresses */
207 #define CONF_MULTICAST 0x46
208 0x0000, 0x0000, 0x0000, /* some addresses */
209 0x0000, 0x0000, 0x0000,
210 0x0000, 0x0000, 0x0000,
211 0x0000, 0x0000, 0x0000,
212 0x0000, 0x0000, 0x0000,
213 0x0000, 0x0000, 0x0000,
214 0x0000, 0x0000, 0x0000,
215 0x0000, 0x0000, 0x0000,
217 #define CONF_DIAG_RESULT 0x76
219 0x007c, /* link to next command */
221 0x0000,Cmd_TDR|Cmd_INT,
223 #define CONF_TDR_RESULT 0x82
226 0x0000,Cmd_END|Cmd_Nop, /* end of configure sequence */
227 0x0084 /* dummy link */
230 /* maps irq number to EtherExpress magic value */
231 static char irqrmap[] = { 0,0,1,2,3,4,0,0,0,1,5,6,0,0,0,0 };
234 /* mapping of the first four bits of the second POS register */
235 static unsigned short mca_iomap[] = {
236 0x270, 0x260, 0x250, 0x240, 0x230, 0x220, 0x210, 0x200,
237 0x370, 0x360, 0x350, 0x340, 0x330, 0x320, 0x310, 0x300
239 /* bits 5-7 of the second POS register */
240 static char mca_irqmap[] = { 12, 9, 3, 4, 5, 10, 11, 15 };
244 * Prototypes for Linux interface
247 static int eexp_open(struct net_device *dev);
248 static int eexp_close(struct net_device *dev);
249 static void eexp_timeout(struct net_device *dev);
250 static struct net_device_stats *eexp_stats(struct net_device *dev);
251 static int eexp_xmit(struct sk_buff *buf, struct net_device *dev);
253 static irqreturn_t eexp_irq(int irq, void *dev_addr, struct pt_regs *regs);
254 static void eexp_set_multicast(struct net_device *dev);
257 * Prototypes for hardware access functions
260 static void eexp_hw_rx_pio(struct net_device *dev);
261 static void eexp_hw_tx_pio(struct net_device *dev, unsigned short *buf,
263 static int eexp_hw_probe(struct net_device *dev,unsigned short ioaddr);
264 static unsigned short eexp_hw_readeeprom(unsigned short ioaddr,
265 unsigned char location);
267 static unsigned short eexp_hw_lasttxstat(struct net_device *dev);
268 static void eexp_hw_txrestart(struct net_device *dev);
270 static void eexp_hw_txinit (struct net_device *dev);
271 static void eexp_hw_rxinit (struct net_device *dev);
273 static void eexp_hw_init586 (struct net_device *dev);
274 static void eexp_setup_filter (struct net_device *dev);
276 static char *eexp_ifmap[]={"AUI", "BNC", "RJ45"};
277 enum eexp_iftype {AUI=0, BNC=1, TPE=2};
283 * Primitive hardware access functions.
286 static inline unsigned short scb_status(struct net_device *dev)
288 return inw(dev->base_addr + 0xc008);
291 static inline unsigned short scb_rdcmd(struct net_device *dev)
293 return inw(dev->base_addr + 0xc00a);
296 static inline void scb_command(struct net_device *dev, unsigned short cmd)
298 outw(cmd, dev->base_addr + 0xc00a);
301 static inline void scb_wrcbl(struct net_device *dev, unsigned short val)
303 outw(val, dev->base_addr + 0xc00c);
306 static inline void scb_wrrfa(struct net_device *dev, unsigned short val)
308 outw(val, dev->base_addr + 0xc00e);
311 static inline void set_loopback(struct net_device *dev)
313 outb(inb(dev->base_addr + Config) | 2, dev->base_addr + Config);
316 static inline void clear_loopback(struct net_device *dev)
318 outb(inb(dev->base_addr + Config) & ~2, dev->base_addr + Config);
321 static inline unsigned short int SHADOW(short int addr)
324 if (addr > 0xf) addr += 0x3ff0;
325 return addr + 0x4000;
333 * checks for presence of EtherExpress card
336 static int __init do_express_probe(struct net_device *dev)
338 unsigned short *port;
339 static unsigned short ports[] = { 0x240,0x300,0x310,0x270,0x320,0x340,0 };
340 unsigned short ioaddr = dev->base_addr;
341 int dev_irq = dev->irq;
344 SET_MODULE_OWNER(dev);
346 dev->if_port = 0xff; /* not set */
353 * Only find one card at a time. Subsequent calls
354 * will find others, however, proper multicard MCA
355 * probing and setup can't be done with the
356 * old-style Space.c init routines. -- ASF
358 while (slot != MCA_NOTFOUND) {
361 slot = mca_find_unused_adapter(0x628B, slot);
362 if (slot == MCA_NOTFOUND)
365 pos0 = mca_read_stored_pos(slot, 2);
366 pos1 = mca_read_stored_pos(slot, 3);
367 ioaddr = mca_iomap[pos1&0xf];
369 dev->irq = mca_irqmap[(pos1>>4)&0x7];
372 * XXX: Transciever selection is done
373 * differently on the MCA version.
374 * How to get it to select something
375 * other than external/AUI is currently
376 * unknown. This code is just for looks. -- ASF
378 if ((pos0 & 0x7) == 0x1)
380 else if ((pos0 & 0x7) == 0x5) {
387 mca_set_adapter_name(slot, "Intel EtherExpress 16 MCA");
388 mca_set_adapter_procfn(slot, NULL, dev);
389 mca_mark_as_used(slot);
396 if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress"))
398 err = eexp_hw_probe(dev,ioaddr);
399 release_region(ioaddr, EEXP_IO_EXTENT);
404 for (port=&ports[0] ; *port ; port++ )
406 unsigned short sum = 0;
408 if (!request_region(*port, EEXP_IO_EXTENT, "EtherExpress"))
410 for ( i=0 ; i<4 ; i++ )
413 t = inb(*port + ID_PORT);
414 sum |= (t>>4) << ((t & 0x03)<<2);
416 if (sum==0xbaba && !eexp_hw_probe(dev,*port)) {
417 release_region(*port, EEXP_IO_EXTENT);
420 release_region(*port, EEXP_IO_EXTENT);
426 struct net_device * __init express_probe(int unit)
428 struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
432 return ERR_PTR(-ENOMEM);
434 sprintf(dev->name, "eth%d", unit);
435 netdev_boot_setup_check(dev);
437 err = do_express_probe(dev);
439 err = register_netdev(dev);
448 * open and initialize the adapter, ready for use
451 static int eexp_open(struct net_device *dev)
454 unsigned short ioaddr = dev->base_addr;
455 struct net_local *lp = netdev_priv(dev);
458 printk(KERN_DEBUG "%s: eexp_open()\n", dev->name);
461 if (!dev->irq || !irqrmap[dev->irq])
464 ret = request_irq(dev->irq,&eexp_irq,0,dev->name,dev);
467 if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress")) {
468 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
472 if (!request_region(ioaddr+0x4000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
473 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
477 if (!request_region(ioaddr+0x8000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
478 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
482 if (!request_region(ioaddr+0xc000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
483 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
489 printk("%s: forcing ASIC to 8-bit mode\n", dev->name);
490 outb(inb(dev->base_addr+Config)&~4, dev->base_addr+Config);
493 eexp_hw_init586(dev);
494 netif_start_queue(dev);
496 printk(KERN_DEBUG "%s: leaving eexp_open()\n", dev->name);
501 release_region(ioaddr+0x8000, EEXP_IO_EXTENT);
503 release_region(ioaddr+0x4000, EEXP_IO_EXTENT);
505 release_region(ioaddr, EEXP_IO_EXTENT);
507 free_irq(dev->irq, dev);
512 * close and disable the interface, leaving the 586 in reset.
515 static int eexp_close(struct net_device *dev)
517 unsigned short ioaddr = dev->base_addr;
518 struct net_local *lp = netdev_priv(dev);
522 netif_stop_queue(dev);
524 outb(SIRQ_dis|irqrmap[irq],ioaddr+SET_IRQ);
526 scb_command(dev, SCB_CUsuspend|SCB_RUsuspend);
527 outb(0,ioaddr+SIGNAL_CA);
529 outb(i586_RST,ioaddr+EEPROM_Ctrl);
530 release_region(ioaddr, EEXP_IO_EXTENT);
531 release_region(ioaddr+0x4000, 16);
532 release_region(ioaddr+0x8000, 16);
533 release_region(ioaddr+0xc000, 16);
539 * Return interface stats
542 static struct net_device_stats *eexp_stats(struct net_device *dev)
544 struct net_local *lp = netdev_priv(dev);
550 * This gets called when a higher level thinks we are broken. Check that
551 * nothing has become jammed in the CU.
554 static void unstick_cu(struct net_device *dev)
556 struct net_local *lp = netdev_priv(dev);
557 unsigned short ioaddr = dev->base_addr;
561 if ((jiffies - dev->trans_start)>50)
563 if (lp->tx_link==lp->last_tx_restart)
565 unsigned short boguscount=200,rsst;
566 printk(KERN_WARNING "%s: Retransmit timed out, status %04x, resetting...\n",
567 dev->name, scb_status(dev));
569 lp->last_tx_restart = 0;
570 scb_wrcbl(dev, lp->tx_link);
571 scb_command(dev, SCB_CUstart);
572 outb(0,ioaddr+SIGNAL_CA);
573 while (!SCB_complete(rsst=scb_status(dev)))
578 printk(KERN_WARNING "%s: Reset timed out status %04x, retrying...\n",
580 scb_wrcbl(dev, lp->tx_link);
581 scb_command(dev, SCB_CUstart);
582 outb(0,ioaddr+SIGNAL_CA);
585 netif_wake_queue(dev);
589 unsigned short status = scb_status(dev);
590 if (SCB_CUdead(status))
592 unsigned short txstatus = eexp_hw_lasttxstat(dev);
593 printk(KERN_WARNING "%s: Transmit timed out, CU not active status %04x %04x, restarting...\n",
594 dev->name, status, txstatus);
595 eexp_hw_txrestart(dev);
599 unsigned short txstatus = eexp_hw_lasttxstat(dev);
600 if (netif_queue_stopped(dev) && !txstatus)
602 printk(KERN_WARNING "%s: CU wedged, status %04x %04x, resetting...\n",
603 dev->name,status,txstatus);
604 eexp_hw_init586(dev);
605 netif_wake_queue(dev);
609 printk(KERN_WARNING "%s: transmit timed out\n", dev->name);
617 if ((jiffies-lp->init_time)>10)
619 unsigned short status = scb_status(dev);
620 printk(KERN_WARNING "%s: i82586 startup timed out, status %04x, resetting...\n",
622 eexp_hw_init586(dev);
623 netif_wake_queue(dev);
628 static void eexp_timeout(struct net_device *dev)
630 struct net_local *lp = netdev_priv(dev);
636 disable_irq(dev->irq);
639 * Best would be to use synchronize_irq(); spin_lock() here
640 * lets make it work first..
644 spin_lock_irqsave(&lp->lock, flags);
647 status = scb_status(dev);
649 printk(KERN_INFO "%s: transmit timed out, %s?\n", dev->name,
650 (SCB_complete(status)?"lost interrupt":
652 lp->stats.tx_errors++;
653 lp->last_tx = jiffies;
654 if (!SCB_complete(status)) {
655 scb_command(dev, SCB_CUabort);
656 outb(0,dev->base_addr+SIGNAL_CA);
658 netif_wake_queue(dev);
660 spin_unlock_irqrestore(&lp->lock, flags);
665 * Called to transmit a packet, or to allow us to right ourselves
666 * if the kernel thinks we've died.
668 static int eexp_xmit(struct sk_buff *buf, struct net_device *dev)
670 struct net_local *lp = netdev_priv(dev);
671 short length = buf->len;
677 printk(KERN_DEBUG "%s: eexp_xmit()\n", dev->name);
680 if (buf->len < ETH_ZLEN) {
681 buf = skb_padto(buf, ETH_ZLEN);
687 disable_irq(dev->irq);
690 * Best would be to use synchronize_irq(); spin_lock() here
691 * lets make it work first..
695 spin_lock_irqsave(&lp->lock, flags);
699 unsigned short *data = (unsigned short *)buf->data;
701 lp->stats.tx_bytes += length;
703 eexp_hw_tx_pio(dev,data,length);
707 spin_unlock_irqrestore(&lp->lock, flags);
709 enable_irq(dev->irq);
714 * Handle an EtherExpress interrupt
715 * If we've finished initializing, start the RU and CU up.
716 * If we've already started, reap tx buffers, handle any received packets,
717 * check to make sure we've not become wedged.
721 * Handle an EtherExpress interrupt
722 * If we've finished initializing, start the RU and CU up.
723 * If we've already started, reap tx buffers, handle any received packets,
724 * check to make sure we've not become wedged.
727 static unsigned short eexp_start_irq(struct net_device *dev,
728 unsigned short status)
730 unsigned short ack_cmd = SCB_ack(status);
731 struct net_local *lp = netdev_priv(dev);
732 unsigned short ioaddr = dev->base_addr;
733 if ((dev->flags & IFF_UP) && !(lp->started & STARTED_CU)) {
734 short diag_status, tdr_status;
735 while (SCB_CUstat(status)==2)
736 status = scb_status(dev);
738 printk("%s: CU went non-active (status %04x)\n",
742 outw(CONF_DIAG_RESULT & ~31, ioaddr + SM_PTR);
743 diag_status = inw(ioaddr + SHADOW(CONF_DIAG_RESULT));
744 if (diag_status & 1<<11) {
745 printk(KERN_WARNING "%s: 82586 failed self-test\n",
747 } else if (!(diag_status & 1<<13)) {
748 printk(KERN_WARNING "%s: 82586 self-test failed to complete\n", dev->name);
751 outw(CONF_TDR_RESULT & ~31, ioaddr + SM_PTR);
752 tdr_status = inw(ioaddr + SHADOW(CONF_TDR_RESULT));
753 if (tdr_status & (TDR_SHORT|TDR_OPEN)) {
754 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" : "");
756 else if (tdr_status & TDR_XCVRPROBLEM) {
757 printk(KERN_WARNING "%s: TDR reports transceiver problem\n", dev->name);
759 else if (tdr_status & TDR_LINKOK) {
761 printk(KERN_DEBUG "%s: TDR reports link OK\n", dev->name);
764 printk("%s: TDR is ga-ga (status %04x)\n", dev->name,
768 lp->started |= STARTED_CU;
769 scb_wrcbl(dev, lp->tx_link);
770 /* if the RU isn't running, start it now */
771 if (!(lp->started & STARTED_RU)) {
772 ack_cmd |= SCB_RUstart;
773 scb_wrrfa(dev, lp->rx_buf_start);
774 lp->rx_ptr = lp->rx_buf_start;
775 lp->started |= STARTED_RU;
777 ack_cmd |= SCB_CUstart | 0x2000;
780 if ((dev->flags & IFF_UP) && !(lp->started & STARTED_RU) && SCB_RUstat(status)==4)
781 lp->started|=STARTED_RU;
786 static void eexp_cmd_clear(struct net_device *dev)
788 unsigned long int oldtime = jiffies;
789 while (scb_rdcmd(dev) && ((jiffies-oldtime)<10));
790 if (scb_rdcmd(dev)) {
791 printk("%s: command didn't clear\n", dev->name);
795 static irqreturn_t eexp_irq(int irq, void *dev_info, struct pt_regs *regs)
797 struct net_device *dev = dev_info;
798 struct net_local *lp;
799 unsigned short ioaddr,status,ack_cmd;
800 unsigned short old_read_ptr, old_write_ptr;
804 printk(KERN_WARNING "eexpress: irq %d for unknown device\n",
809 lp = netdev_priv(dev);
810 ioaddr = dev->base_addr;
812 spin_lock(&lp->lock);
814 old_read_ptr = inw(ioaddr+READ_PTR);
815 old_write_ptr = inw(ioaddr+WRITE_PTR);
817 outb(SIRQ_dis|irqrmap[irq],ioaddr+SET_IRQ);
820 status = scb_status(dev);
823 printk(KERN_DEBUG "%s: interrupt (status %x)\n", dev->name, status);
826 if (lp->started == (STARTED_CU | STARTED_RU)) {
831 ack_cmd = SCB_ack(status);
832 scb_command(dev, ack_cmd);
833 outb(0,ioaddr+SIGNAL_CA);
837 if (SCB_complete(status)) {
838 if (!eexp_hw_lasttxstat(dev)) {
839 printk("%s: tx interrupt but no status\n", dev->name);
843 if (SCB_rxdframe(status))
846 status = scb_status(dev);
847 } while (status & 0xc000);
849 if (SCB_RUdead(status))
851 printk(KERN_WARNING "%s: RU stopped: status %04x\n",
854 printk(KERN_WARNING "%s: cur_rfd=%04x, cur_rbd=%04x\n", dev->name, lp->cur_rfd, lp->cur_rbd);
855 outw(lp->cur_rfd, ioaddr+READ_PTR);
856 printk(KERN_WARNING "%s: [%04x]\n", dev->name, inw(ioaddr+DATAPORT));
857 outw(lp->cur_rfd+6, ioaddr+READ_PTR);
858 printk(KERN_WARNING "%s: rbd is %04x\n", dev->name, rbd= inw(ioaddr+DATAPORT));
859 outw(rbd, ioaddr+READ_PTR);
860 printk(KERN_WARNING "%s: [%04x %04x] ", dev->name, inw(ioaddr+DATAPORT), inw(ioaddr+DATAPORT));
861 outw(rbd+8, ioaddr+READ_PTR);
862 printk("[%04x]\n", inw(ioaddr+DATAPORT));
864 lp->stats.rx_errors++;
868 lp->cur_rfd = lp->first_rfd;
870 scb_wrrfa(dev, lp->rx_buf_start);
871 scb_command(dev, SCB_RUstart);
872 outb(0,ioaddr+SIGNAL_CA);
876 ack_cmd = eexp_start_irq(dev, status);
878 ack_cmd = SCB_ack(status);
879 scb_command(dev, ack_cmd);
880 outb(0,ioaddr+SIGNAL_CA);
885 outb(SIRQ_en|irqrmap[irq],ioaddr+SET_IRQ);
888 printk("%s: leaving eexp_irq()\n", dev->name);
890 outw(old_read_ptr, ioaddr+READ_PTR);
891 outw(old_write_ptr, ioaddr+WRITE_PTR);
893 spin_unlock(&lp->lock);
898 * Hardware access functions
902 * Set the cable type to use.
905 static void eexp_hw_set_interface(struct net_device *dev)
907 unsigned char oldval = inb(dev->base_addr + 0x300e);
909 switch (dev->if_port) {
916 outb(oldval, dev->base_addr+0x300e);
921 * Check all the receive buffers, and hand any received packets
922 * to the upper levels. Basic sanity check on each frame
923 * descriptor, though we don't bother trying to fix broken ones.
926 static void eexp_hw_rx_pio(struct net_device *dev)
928 struct net_local *lp = netdev_priv(dev);
929 unsigned short rx_block = lp->rx_ptr;
930 unsigned short boguscount = lp->num_rx_bufs;
931 unsigned short ioaddr = dev->base_addr;
932 unsigned short status;
935 printk(KERN_DEBUG "%s: eexp_hw_rx()\n", dev->name);
939 unsigned short rfd_cmd, rx_next, pbuf, pkt_len;
941 outw(rx_block, ioaddr + READ_PTR);
942 status = inw(ioaddr + DATAPORT);
946 rfd_cmd = inw(ioaddr + DATAPORT);
947 rx_next = inw(ioaddr + DATAPORT);
948 pbuf = inw(ioaddr + DATAPORT);
950 outw(pbuf, ioaddr + READ_PTR);
951 pkt_len = inw(ioaddr + DATAPORT);
955 printk(KERN_WARNING "%s: rfd_cmd not zero:0x%04x\n",
959 else if (pbuf!=rx_block+0x16)
961 printk(KERN_WARNING "%s: rfd and rbd out of sync 0x%04x 0x%04x\n",
962 dev->name, rx_block+0x16, pbuf);
965 else if ((pkt_len & 0xc000)!=0xc000)
967 printk(KERN_WARNING "%s: EOF or F not set on received buffer (%04x)\n",
968 dev->name, pkt_len & 0xc000);
971 else if (!FD_OK(status))
973 lp->stats.rx_errors++;
975 lp->stats.rx_crc_errors++;
976 if (FD_Align(status))
977 lp->stats.rx_frame_errors++;
978 if (FD_Resrc(status))
979 lp->stats.rx_fifo_errors++;
981 lp->stats.rx_over_errors++;
982 if (FD_Short(status))
983 lp->stats.rx_length_errors++;
989 skb = dev_alloc_skb(pkt_len+16);
992 printk(KERN_WARNING "%s: Memory squeeze, dropping packet\n",dev->name);
993 lp->stats.rx_dropped++;
998 outw(pbuf+10, ioaddr+READ_PTR);
999 insw(ioaddr+DATAPORT, skb_put(skb,pkt_len),(pkt_len+1)>>1);
1000 skb->protocol = eth_type_trans(skb,dev);
1002 dev->last_rx = jiffies;
1003 lp->stats.rx_packets++;
1004 lp->stats.rx_bytes += pkt_len;
1006 outw(rx_block, ioaddr+WRITE_PTR);
1007 outw(0, ioaddr+DATAPORT);
1008 outw(0, ioaddr+DATAPORT);
1011 } while (FD_Done(status) && boguscount--);
1012 lp->rx_ptr = rx_block;
1016 * Hand a packet to the card for transmission
1017 * If we get here, we MUST have already checked
1018 * to make sure there is room in the transmit
1022 static void eexp_hw_tx_pio(struct net_device *dev, unsigned short *buf,
1025 struct net_local *lp = netdev_priv(dev);
1026 unsigned short ioaddr = dev->base_addr;
1028 if (LOCKUP16 || lp->width) {
1029 /* Stop the CU so that there is no chance that it
1030 jumps off to a bogus address while we are writing the
1031 pointer to the next transmit packet in 8-bit mode --
1032 this eliminates the "CU wedged" errors in 8-bit mode.
1033 (Zoltan Szilagyi 10-12-96) */
1034 scb_command(dev, SCB_CUsuspend);
1035 outw(0xFFFF, ioaddr+SIGNAL_CA);
1038 outw(lp->tx_head, ioaddr + WRITE_PTR);
1040 outw(0x0000, ioaddr + DATAPORT);
1041 outw(Cmd_INT|Cmd_Xmit, ioaddr + DATAPORT);
1042 outw(lp->tx_head+0x08, ioaddr + DATAPORT);
1043 outw(lp->tx_head+0x0e, ioaddr + DATAPORT);
1045 outw(0x0000, ioaddr + DATAPORT);
1046 outw(0x0000, ioaddr + DATAPORT);
1047 outw(lp->tx_head+0x08, ioaddr + DATAPORT);
1049 outw(0x8000|len, ioaddr + DATAPORT);
1050 outw(-1, ioaddr + DATAPORT);
1051 outw(lp->tx_head+0x16, ioaddr + DATAPORT);
1052 outw(0, ioaddr + DATAPORT);
1054 outsw(ioaddr + DATAPORT, buf, (len+1)>>1);
1056 outw(lp->tx_tail+0xc, ioaddr + WRITE_PTR);
1057 outw(lp->tx_head, ioaddr + DATAPORT);
1059 dev->trans_start = jiffies;
1060 lp->tx_tail = lp->tx_head;
1061 if (lp->tx_head==TX_BUF_START+((lp->num_tx_bufs-1)*TX_BUF_SIZE))
1062 lp->tx_head = TX_BUF_START;
1064 lp->tx_head += TX_BUF_SIZE;
1065 if (lp->tx_head != lp->tx_reap)
1066 netif_wake_queue(dev);
1068 if (LOCKUP16 || lp->width) {
1069 /* Restart the CU so that the packet can actually
1070 be transmitted. (Zoltan Szilagyi 10-12-96) */
1071 scb_command(dev, SCB_CUresume);
1072 outw(0xFFFF, ioaddr+SIGNAL_CA);
1075 lp->stats.tx_packets++;
1076 lp->last_tx = jiffies;
1080 * Sanity check the suspected EtherExpress card
1081 * Read hardware address, reset card, size memory and initialize buffer
1082 * memory pointers. These are held in dev->priv, in case someone has more
1083 * than one card in a machine.
1086 static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
1088 unsigned short hw_addr[3];
1089 unsigned char buswidth;
1090 unsigned int memory_size;
1092 unsigned short xsum = 0;
1093 struct net_local *lp = netdev_priv(dev);
1095 printk("%s: EtherExpress 16 at %#x ",dev->name,ioaddr);
1097 outb(ASIC_RST, ioaddr+EEPROM_Ctrl);
1098 outb(0, ioaddr+EEPROM_Ctrl);
1100 outb(i586_RST, ioaddr+EEPROM_Ctrl);
1102 hw_addr[0] = eexp_hw_readeeprom(ioaddr,2);
1103 hw_addr[1] = eexp_hw_readeeprom(ioaddr,3);
1104 hw_addr[2] = eexp_hw_readeeprom(ioaddr,4);
1106 /* Standard Address or Compaq LTE Address */
1107 if (!((hw_addr[2]==0x00aa && ((hw_addr[1] & 0xff00)==0x0000)) ||
1108 (hw_addr[2]==0x0080 && ((hw_addr[1] & 0xff00)==0x5F00))))
1110 printk(" rejected: invalid address %04x%04x%04x\n",
1111 hw_addr[2],hw_addr[1],hw_addr[0]);
1115 /* Calculate the EEPROM checksum. Carry on anyway if it's bad,
1118 for (i = 0; i < 64; i++)
1119 xsum += eexp_hw_readeeprom(ioaddr, i);
1121 printk(" (bad EEPROM xsum 0x%02x)", xsum);
1123 dev->base_addr = ioaddr;
1124 for ( i=0 ; i<6 ; i++ )
1125 dev->dev_addr[i] = ((unsigned char *)hw_addr)[5-i];
1128 static char irqmap[]={0, 9, 3, 4, 5, 10, 11, 0};
1129 unsigned short setupval = eexp_hw_readeeprom(ioaddr,0);
1131 /* Use the IRQ from EEPROM if none was given */
1133 dev->irq = irqmap[setupval>>13];
1135 if (dev->if_port == 0xff) {
1136 dev->if_port = !(setupval & 0x1000) ? AUI :
1137 eexp_hw_readeeprom(ioaddr,5) & 0x1 ? TPE : BNC;
1140 buswidth = !((setupval & 0x400) >> 10);
1143 memset(lp, 0, sizeof(struct net_local));
1144 spin_lock_init(&lp->lock);
1146 printk("(IRQ %d, %s connector, %d-bit bus", dev->irq,
1147 eexp_ifmap[dev->if_port], buswidth?8:16);
1149 if (!request_region(dev->base_addr + 0x300e, 1, "EtherExpress"))
1152 eexp_hw_set_interface(dev);
1154 release_region(dev->base_addr + 0x300e, 1);
1156 /* Find out how much RAM we have on the card */
1157 outw(0, dev->base_addr + WRITE_PTR);
1158 for (i = 0; i < 32768; i++)
1159 outw(0, dev->base_addr + DATAPORT);
1161 for (memory_size = 0; memory_size < 64; memory_size++)
1163 outw(memory_size<<10, dev->base_addr + READ_PTR);
1164 if (inw(dev->base_addr+DATAPORT))
1166 outw(memory_size<<10, dev->base_addr + WRITE_PTR);
1167 outw(memory_size | 0x5000, dev->base_addr+DATAPORT);
1168 outw(memory_size<<10, dev->base_addr + READ_PTR);
1169 if (inw(dev->base_addr+DATAPORT) != (memory_size | 0x5000))
1173 /* Sort out the number of buffers. We may have 16, 32, 48 or 64k
1174 * of RAM to play with.
1176 lp->num_tx_bufs = 4;
1177 lp->rx_buf_end = 0x3ff6;
1178 switch (memory_size)
1181 lp->rx_buf_end += 0x4000;
1183 lp->num_tx_bufs += 4;
1184 lp->rx_buf_end += 0x4000;
1186 lp->rx_buf_end += 0x4000;
1188 printk(", %dk RAM)\n", memory_size);
1191 printk(") bad memory size (%dk).\n", memory_size);
1196 lp->rx_buf_start = TX_BUF_START + (lp->num_tx_bufs*TX_BUF_SIZE);
1197 lp->width = buswidth;
1199 dev->open = eexp_open;
1200 dev->stop = eexp_close;
1201 dev->hard_start_xmit = eexp_xmit;
1202 dev->get_stats = eexp_stats;
1203 dev->set_multicast_list = &eexp_set_multicast;
1204 dev->tx_timeout = eexp_timeout;
1205 dev->watchdog_timeo = 2*HZ;
1210 * Read a word from the EtherExpress on-board serial EEPROM.
1211 * The EEPROM contains 64 words of 16 bits.
1213 static unsigned short __init eexp_hw_readeeprom(unsigned short ioaddr,
1214 unsigned char location)
1216 unsigned short cmd = 0x180|(location&0x7f);
1217 unsigned short rval = 0,wval = EC_CS|i586_RST;
1220 outb(EC_CS|i586_RST,ioaddr+EEPROM_Ctrl);
1221 for (i=0x100 ; i ; i>>=1 )
1228 outb(wval,ioaddr+EEPROM_Ctrl);
1229 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1231 outb(wval,ioaddr+EEPROM_Ctrl);
1235 outb(wval,ioaddr+EEPROM_Ctrl);
1236 for (i=0x8000 ; i ; i>>=1 )
1238 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1240 if (inb(ioaddr+EEPROM_Ctrl)&EC_Rd)
1242 outb(wval,ioaddr+EEPROM_Ctrl);
1246 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1248 outb(wval,ioaddr+EEPROM_Ctrl);
1254 * Reap tx buffers and return last transmit status.
1255 * if ==0 then either:
1256 * a) we're not transmitting anything, so why are we here?
1258 * otherwise, Stat_Busy(return) means we've still got some packets
1259 * to transmit, Stat_Done(return) means our buffers should be empty
1263 static unsigned short eexp_hw_lasttxstat(struct net_device *dev)
1265 struct net_local *lp = netdev_priv(dev);
1266 unsigned short tx_block = lp->tx_reap;
1267 unsigned short status;
1269 if (!netif_queue_stopped(dev) && lp->tx_head==lp->tx_reap)
1274 outw(tx_block & ~31, dev->base_addr + SM_PTR);
1275 status = inw(dev->base_addr + SHADOW(tx_block));
1276 if (!Stat_Done(status))
1278 lp->tx_link = tx_block;
1283 lp->last_tx_restart = 0;
1284 lp->stats.collisions += Stat_NoColl(status);
1285 if (!Stat_OK(status))
1287 char *whatsup = NULL;
1288 lp->stats.tx_errors++;
1289 if (Stat_Abort(status))
1290 lp->stats.tx_aborted_errors++;
1291 if (Stat_TNoCar(status)) {
1292 whatsup = "aborted, no carrier";
1293 lp->stats.tx_carrier_errors++;
1295 if (Stat_TNoCTS(status)) {
1296 whatsup = "aborted, lost CTS";
1297 lp->stats.tx_carrier_errors++;
1299 if (Stat_TNoDMA(status)) {
1300 whatsup = "FIFO underran";
1301 lp->stats.tx_fifo_errors++;
1303 if (Stat_TXColl(status)) {
1304 whatsup = "aborted, too many collisions";
1305 lp->stats.tx_aborted_errors++;
1308 printk(KERN_INFO "%s: transmit %s\n",
1309 dev->name, whatsup);
1312 lp->stats.tx_packets++;
1314 if (tx_block == TX_BUF_START+((lp->num_tx_bufs-1)*TX_BUF_SIZE))
1315 lp->tx_reap = tx_block = TX_BUF_START;
1317 lp->tx_reap = tx_block += TX_BUF_SIZE;
1318 netif_wake_queue(dev);
1320 while (lp->tx_reap != lp->tx_head);
1322 lp->tx_link = lp->tx_tail + 0x08;
1328 * This should never happen. It is called when some higher routine detects
1329 * that the CU has stopped, to try to restart it from the last packet we knew
1330 * we were working on, or the idle loop if we had finished for the time.
1333 static void eexp_hw_txrestart(struct net_device *dev)
1335 struct net_local *lp = netdev_priv(dev);
1336 unsigned short ioaddr = dev->base_addr;
1338 lp->last_tx_restart = lp->tx_link;
1339 scb_wrcbl(dev, lp->tx_link);
1340 scb_command(dev, SCB_CUstart);
1341 outb(0,ioaddr+SIGNAL_CA);
1344 unsigned short boguscount=50,failcount=5;
1345 while (!scb_status(dev))
1351 printk(KERN_WARNING "%s: CU start timed out, status %04x, cmd %04x\n", dev->name, scb_status(dev), scb_rdcmd(dev));
1352 scb_wrcbl(dev, lp->tx_link);
1353 scb_command(dev, SCB_CUstart);
1354 outb(0,ioaddr+SIGNAL_CA);
1359 printk(KERN_WARNING "%s: Failed to restart CU, resetting board...\n",dev->name);
1360 eexp_hw_init586(dev);
1361 netif_wake_queue(dev);
1370 * Writes down the list of transmit buffers into card memory. Each
1371 * entry consists of an 82586 transmit command, followed by a jump
1372 * pointing to itself. When we want to transmit a packet, we write
1373 * the data into the appropriate transmit buffer and then modify the
1374 * preceding jump to point at the new transmit command. This means that
1375 * the 586 command unit is continuously active.
1378 static void eexp_hw_txinit(struct net_device *dev)
1380 struct net_local *lp = netdev_priv(dev);
1381 unsigned short tx_block = TX_BUF_START;
1382 unsigned short curtbuf;
1383 unsigned short ioaddr = dev->base_addr;
1385 for ( curtbuf=0 ; curtbuf<lp->num_tx_bufs ; curtbuf++ )
1387 outw(tx_block, ioaddr + WRITE_PTR);
1389 outw(0x0000, ioaddr + DATAPORT);
1390 outw(Cmd_INT|Cmd_Xmit, ioaddr + DATAPORT);
1391 outw(tx_block+0x08, ioaddr + DATAPORT);
1392 outw(tx_block+0x0e, ioaddr + DATAPORT);
1394 outw(0x0000, ioaddr + DATAPORT);
1395 outw(0x0000, ioaddr + DATAPORT);
1396 outw(tx_block+0x08, ioaddr + DATAPORT);
1398 outw(0x8000, ioaddr + DATAPORT);
1399 outw(-1, ioaddr + DATAPORT);
1400 outw(tx_block+0x16, ioaddr + DATAPORT);
1401 outw(0x0000, ioaddr + DATAPORT);
1403 tx_block += TX_BUF_SIZE;
1405 lp->tx_head = TX_BUF_START;
1406 lp->tx_reap = TX_BUF_START;
1407 lp->tx_tail = tx_block - TX_BUF_SIZE;
1408 lp->tx_link = lp->tx_tail + 0x08;
1409 lp->rx_buf_start = tx_block;
1414 * Write the circular list of receive buffer descriptors to card memory.
1415 * The end of the list isn't marked, which means that the 82586 receive
1416 * unit will loop until buffers become available (this avoids it giving us
1417 * "out of resources" messages).
1420 static void eexp_hw_rxinit(struct net_device *dev)
1422 struct net_local *lp = netdev_priv(dev);
1423 unsigned short rx_block = lp->rx_buf_start;
1424 unsigned short ioaddr = dev->base_addr;
1426 lp->num_rx_bufs = 0;
1427 lp->rx_first = lp->rx_ptr = rx_block;
1432 outw(rx_block, ioaddr + WRITE_PTR);
1434 outw(0, ioaddr + DATAPORT); outw(0, ioaddr+DATAPORT);
1435 outw(rx_block + RX_BUF_SIZE, ioaddr+DATAPORT);
1436 outw(0xffff, ioaddr+DATAPORT);
1438 outw(0x0000, ioaddr+DATAPORT);
1439 outw(0xdead, ioaddr+DATAPORT);
1440 outw(0xdead, ioaddr+DATAPORT);
1441 outw(0xdead, ioaddr+DATAPORT);
1442 outw(0xdead, ioaddr+DATAPORT);
1443 outw(0xdead, ioaddr+DATAPORT);
1444 outw(0xdead, ioaddr+DATAPORT);
1446 outw(0x0000, ioaddr+DATAPORT);
1447 outw(rx_block + RX_BUF_SIZE + 0x16, ioaddr+DATAPORT);
1448 outw(rx_block + 0x20, ioaddr+DATAPORT);
1449 outw(0, ioaddr+DATAPORT);
1450 outw(RX_BUF_SIZE-0x20, ioaddr+DATAPORT);
1452 lp->rx_last = rx_block;
1453 rx_block += RX_BUF_SIZE;
1454 } while (rx_block <= lp->rx_buf_end-RX_BUF_SIZE);
1457 /* Make first Rx frame descriptor point to first Rx buffer
1459 outw(lp->rx_first + 6, ioaddr+WRITE_PTR);
1460 outw(lp->rx_first + 0x16, ioaddr+DATAPORT);
1462 /* Close Rx frame descriptor ring */
1463 outw(lp->rx_last + 4, ioaddr+WRITE_PTR);
1464 outw(lp->rx_first, ioaddr+DATAPORT);
1466 /* Close Rx buffer descriptor ring */
1467 outw(lp->rx_last + 0x16 + 2, ioaddr+WRITE_PTR);
1468 outw(lp->rx_first + 0x16, ioaddr+DATAPORT);
1473 * Un-reset the 586, and start the configuration sequence. We don't wait for
1474 * this to finish, but allow the interrupt handler to start the CU and RU for
1475 * us. We can't start the receive/transmission system up before we know that
1476 * the hardware is configured correctly.
1479 static void eexp_hw_init586(struct net_device *dev)
1481 struct net_local *lp = netdev_priv(dev);
1482 unsigned short ioaddr = dev->base_addr;
1486 printk("%s: eexp_hw_init586()\n", dev->name);
1493 outb(SIRQ_dis|irqrmap[dev->irq],ioaddr+SET_IRQ);
1495 /* Download the startup code */
1496 outw(lp->rx_buf_end & ~31, ioaddr + SM_PTR);
1497 outw(lp->width?0x0001:0x0000, ioaddr + 0x8006);
1498 outw(0x0000, ioaddr + 0x8008);
1499 outw(0x0000, ioaddr + 0x800a);
1500 outw(0x0000, ioaddr + 0x800c);
1501 outw(0x0000, ioaddr + 0x800e);
1503 for (i = 0; i < (sizeof(start_code)); i+=32) {
1505 outw(i, ioaddr + SM_PTR);
1506 for (j = 0; j < 16; j+=2)
1507 outw(start_code[(i+j)/2],
1509 for (j = 0; j < 16; j+=2)
1510 outw(start_code[(i+j+16)/2],
1514 /* Do we want promiscuous mode or multicast? */
1515 outw(CONF_PROMISC & ~31, ioaddr+SM_PTR);
1516 i = inw(ioaddr+SHADOW(CONF_PROMISC));
1517 outw((dev->flags & IFF_PROMISC)?(i|1):(i & ~1),
1518 ioaddr+SHADOW(CONF_PROMISC));
1519 lp->was_promisc = dev->flags & IFF_PROMISC;
1521 eexp_setup_filter(dev);
1524 /* Write our hardware address */
1525 outw(CONF_HWADDR & ~31, ioaddr+SM_PTR);
1526 outw(((unsigned short *)dev->dev_addr)[0], ioaddr+SHADOW(CONF_HWADDR));
1527 outw(((unsigned short *)dev->dev_addr)[1],
1528 ioaddr+SHADOW(CONF_HWADDR+2));
1529 outw(((unsigned short *)dev->dev_addr)[2],
1530 ioaddr+SHADOW(CONF_HWADDR+4));
1532 eexp_hw_txinit(dev);
1533 eexp_hw_rxinit(dev);
1535 outb(0,ioaddr+EEPROM_Ctrl);
1538 scb_command(dev, 0xf000);
1539 outb(0,ioaddr+SIGNAL_CA);
1541 outw(0, ioaddr+SM_PTR);
1544 unsigned short rboguscount=50,rfailcount=5;
1545 while (inw(ioaddr+0x4000))
1549 printk(KERN_WARNING "%s: i82586 reset timed out, kicking...\n",
1551 scb_command(dev, 0);
1552 outb(0,ioaddr+SIGNAL_CA);
1556 printk(KERN_WARNING "%s: i82586 not responding, giving up.\n",
1564 scb_wrcbl(dev, CONF_LINK);
1565 scb_command(dev, 0xf000|SCB_CUstart);
1566 outb(0,ioaddr+SIGNAL_CA);
1569 unsigned short iboguscount=50,ifailcount=5;
1570 while (!scb_status(dev))
1576 printk(KERN_WARNING "%s: i82586 initialization timed out, status %04x, cmd %04x\n",
1577 dev->name, scb_status(dev), scb_rdcmd(dev));
1578 scb_wrcbl(dev, CONF_LINK);
1579 scb_command(dev, 0xf000|SCB_CUstart);
1580 outb(0,ioaddr+SIGNAL_CA);
1585 printk(KERN_WARNING "%s: Failed to initialize i82586, giving up.\n",dev->name);
1592 clear_loopback(dev);
1593 outb(SIRQ_en|irqrmap[dev->irq],ioaddr+SET_IRQ);
1595 lp->init_time = jiffies;
1597 printk("%s: leaving eexp_hw_init586()\n", dev->name);
1602 static void eexp_setup_filter(struct net_device *dev)
1604 struct dev_mc_list *dmi = dev->mc_list;
1605 unsigned short ioaddr = dev->base_addr;
1606 int count = dev->mc_count;
1609 printk(KERN_INFO "%s: too many multicast addresses (%d)\n",
1614 outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR);
1615 outw(count, ioaddr+SHADOW(CONF_NR_MULTICAST));
1616 for (i = 0; i < count; i++) {
1617 unsigned short *data = (unsigned short *)dmi->dmi_addr;
1619 printk(KERN_INFO "%s: too few multicast addresses\n", dev->name);
1622 if (dmi->dmi_addrlen != ETH_ALEN) {
1623 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
1626 outw((CONF_MULTICAST+(6*i)) & ~31, ioaddr+SM_PTR);
1627 outw(data[0], ioaddr+SHADOW(CONF_MULTICAST+(6*i)));
1628 outw((CONF_MULTICAST+(6*i)+2) & ~31, ioaddr+SM_PTR);
1629 outw(data[1], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+2));
1630 outw((CONF_MULTICAST+(6*i)+4) & ~31, ioaddr+SM_PTR);
1631 outw(data[2], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+4));
1636 * Set or clear the multicast filter for this adaptor.
1639 eexp_set_multicast(struct net_device *dev)
1641 unsigned short ioaddr = dev->base_addr;
1642 struct net_local *lp = netdev_priv(dev);
1644 if ((dev->flags & IFF_PROMISC) != lp->was_promisc) {
1645 outw(CONF_PROMISC & ~31, ioaddr+SM_PTR);
1646 i = inw(ioaddr+SHADOW(CONF_PROMISC));
1647 outw((dev->flags & IFF_PROMISC)?(i|1):(i & ~1),
1648 ioaddr+SHADOW(CONF_PROMISC));
1649 lp->was_promisc = dev->flags & IFF_PROMISC;
1652 if (!(dev->flags & IFF_PROMISC)) {
1653 eexp_setup_filter(dev);
1654 if (lp->old_mc_count != dev->mc_count) {
1656 lp->old_mc_count = dev->mc_count;
1661 scb_command(dev, SCB_CUsuspend);
1662 outb(0, ioaddr+SIGNAL_CA);
1663 outb(0, ioaddr+SIGNAL_CA);
1665 printk("%s: waiting for CU to go suspended\n", dev->name);
1668 while ((SCB_CUstat(scb_status(dev)) == 2) &&
1669 ((jiffies-oj) < 2000));
1670 if (SCB_CUstat(scb_status(dev)) == 2)
1671 printk("%s: warning, CU didn't stop\n", dev->name);
1672 lp->started &= ~(STARTED_CU);
1673 scb_wrcbl(dev, CONF_LINK);
1674 scb_command(dev, SCB_CUstart);
1675 outb(0, ioaddr+SIGNAL_CA);
1686 #define EEXP_MAX_CARDS 4 /* max number of cards to support */
1688 static struct net_device *dev_eexp[EEXP_MAX_CARDS];
1689 static int irq[EEXP_MAX_CARDS];
1690 static int io[EEXP_MAX_CARDS];
1692 MODULE_PARM(io, "1-" __MODULE_STRING(EEXP_MAX_CARDS) "i");
1693 MODULE_PARM(irq, "1-" __MODULE_STRING(EEXP_MAX_CARDS) "i");
1694 MODULE_PARM_DESC(io, "EtherExpress 16 I/O base address(es)");
1695 MODULE_PARM_DESC(irq, "EtherExpress 16 IRQ number(s)");
1696 MODULE_LICENSE("GPL");
1699 /* Ideally the user would give us io=, irq= for every card. If any parameters
1700 * are specified, we verify and then use them. If no parameters are given, we
1701 * autoprobe for one card only.
1703 int init_module(void)
1705 struct net_device *dev;
1706 int this_dev, found = 0;
1708 for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
1709 dev = alloc_etherdev(sizeof(struct net_local));
1710 dev->irq = irq[this_dev];
1711 dev->base_addr = io[this_dev];
1712 if (io[this_dev] == 0) {
1715 printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n");
1717 if (do_express_probe(dev) == 0 && register_netdev(dev) == 0) {
1718 dev_eexp[this_dev] = dev;
1722 printk(KERN_WARNING "eexpress.c: Failed to register card at 0x%x.\n", io[this_dev]);
1731 void cleanup_module(void)
1735 for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
1736 struct net_device *dev = dev_eexp[this_dev];
1738 unregister_netdev(dev);
1747 * c-file-style: "linux"