setup enviroment for compilation
[linux-2.4.21-pre4.git] / drivers / net / fmv18x.c
1 /* fmv18x.c: A network device driver for the Fujitsu FMV-181/182/183/184.
2
3         Original: at1700.c (1993-94 by Donald Becker).
4                 Copyright 1993 United States Government as represented by the
5                 Director, National Security Agency.
6                 The author may be reached as becker@scyld.com, or C/O
7                         Scyld Computing Corporation
8                         410 Severn Ave., Suite 210
9                         Annapolis MD 21403
10
11         Modified by Yutaka TAMIYA (tamy@flab.fujitsu.co.jp)
12                 Copyright 1994 Fujitsu Laboratories Ltd.
13         Special thanks to:
14                 Masayoshi UTAKA (utaka@ace.yk.fujitsu.co.jp)
15                         for testing this driver.
16                 H. NEGISHI (agy, negishi@sun45.psd.cs.fujitsu.co.jp)
17                         for suggestion of some program modification.
18                 Masahiro SEKIGUCHI <seki@sysrap.cs.fujitsu.co.jp>
19                         for suggestion of some program modification.
20                 Kazutoshi MORIOKA (morioka@aurora.oaks.cs.fujitsu.co.jp)
21                         for testing this driver.
22
23         This software may be used and distributed according to the terms
24         of the GNU General Public License, incorporated herein by reference.
25
26         This is a device driver for the Fujitsu FMV-181/182/183/184, which
27         is a straight-forward Fujitsu MB86965 implementation.
28
29   Sources:
30     at1700.c
31     The Fujitsu MB86965 datasheet.
32     The Fujitsu FMV-181/182 user's guide
33 */
34
35 static const char version[] =
36         "fmv18x.c:v2.2.0 09/24/98  Yutaka TAMIYA (tamy@flab.fujitsu.co.jp)\n";
37
38 #include <linux/module.h>
39
40 #include <linux/kernel.h>
41 #include <linux/sched.h>
42 #include <linux/types.h>
43 #include <linux/fcntl.h>
44 #include <linux/interrupt.h>
45 #include <linux/ptrace.h>
46 #include <linux/ioport.h>
47 #include <linux/in.h>
48 #include <linux/slab.h>
49 #include <linux/string.h>
50 #include <linux/init.h>
51 #include <asm/system.h>
52 #include <asm/bitops.h>
53 #include <asm/io.h>
54 #include <asm/dma.h>
55 #include <linux/errno.h>
56 #include <linux/spinlock.h>
57
58 #include <linux/netdevice.h>
59 #include <linux/etherdevice.h>
60 #include <linux/skbuff.h>
61 #include <linux/delay.h>
62
63 static int fmv18x_probe_list[] __initdata = {
64         0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x300, 0x340, 0
65 };
66
67 /* use 0 for production, 1 for verification, >2 for debug */
68 #ifndef NET_DEBUG
69 #define NET_DEBUG 1
70 #endif
71 static unsigned int net_debug = NET_DEBUG;
72
73 typedef unsigned char uchar;
74
75 /* Information that need to be kept for each board. */
76 struct net_local {
77         struct net_device_stats stats;
78         long open_time;                         /* Useless example local info. */
79         uint tx_started:1;                      /* Number of packet on the Tx queue. */
80         uint tx_queue_ready:1;          /* Tx queue is ready to be sent. */
81         uint rx_started:1;                      /* Packets are Rxing. */
82         uchar tx_queue;                         /* Number of packet on the Tx queue. */
83         ushort tx_queue_len;            /* Current length of the Tx queue. */
84         spinlock_t lock;
85 };
86
87
88 /* Offsets from the base address. */
89 #define STATUS                  0
90 #define TX_STATUS               0
91 #define RX_STATUS               1
92 #define TX_INTR                 2               /* Bit-mapped interrupt enable registers. */
93 #define RX_INTR                 3
94 #define TX_MODE                 4
95 #define RX_MODE                 5
96 #define CONFIG_0                6               /* Misc. configuration settings. */
97 #define CONFIG_1                7
98 /* Run-time register bank 2 definitions. */
99 #define DATAPORT                8               /* Word-wide DMA or programmed-I/O dataport. */
100 #define TX_START                10
101 #define COL16CNTL               11              /* Controll Reg for 16 collisions */
102 #define MODE13                  13
103 /* Fujitsu FMV-18x Card Configuration */
104 #define FJ_STATUS0              0x10
105 #define FJ_STATUS1              0x11
106 #define FJ_CONFIG0              0x12
107 #define FJ_CONFIG1              0x13
108 #define FJ_MACADDR              0x14    /* 0x14 - 0x19 */
109 #define FJ_BUFCNTL              0x1A
110 #define FJ_BUFDATA              0x1C
111 #define FMV18X_IO_EXTENT        32
112
113 /* Index to functions, as function prototypes. */
114
115 extern int fmv18x_probe(struct net_device *dev);
116
117 static int fmv18x_probe1(struct net_device *dev, short ioaddr);
118 static int net_open(struct net_device *dev);
119 static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
120 static void net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
121 static void net_rx(struct net_device *dev);
122 static void net_timeout(struct net_device *dev);
123 static int net_close(struct net_device *dev);
124 static struct net_device_stats *net_get_stats(struct net_device *dev);
125 static void set_multicast_list(struct net_device *dev);
126
127 \f
128 /* Check for a network adaptor of this type, and return '0' iff one exists.
129    If dev->base_addr == 0, probe all likely locations.
130    If dev->base_addr == 1, always return failure.
131    If dev->base_addr == 2, allocate space for the device and return success
132    (detachable devices only).
133    */
134
135 int __init fmv18x_probe(struct net_device *dev)
136 {
137         int i;
138         int base_addr = dev->base_addr;
139
140         SET_MODULE_OWNER(dev);
141
142         if (base_addr > 0x1ff)          /* Check a single specified location. */
143                 return fmv18x_probe1(dev, base_addr);
144         else if (base_addr != 0)        /* Don't probe at all. */
145                 return -ENXIO;
146
147         for (i = 0; fmv18x_probe_list[i]; i++)
148                 if (fmv18x_probe1(dev, fmv18x_probe_list[i]) == 0)
149                         return 0;
150
151         return -ENODEV;
152 }
153
154 /* The Fujitsu datasheet suggests that the NIC be probed for by checking its
155    "signature", the default bit pattern after a reset.  This *doesn't* work --
156    there is no way to reset the bus interface without a complete power-cycle!
157
158    It turns out that ATI came to the same conclusion I did: the only thing
159    that can be done is checking a few bits and then diving right into MAC
160    address check. */
161
162 static int __init fmv18x_probe1(struct net_device *dev, short ioaddr)
163 {
164         char irqmap[4] = {3, 7, 10, 15};
165         char irqmap_pnp[8] = {3, 4, 5, 7, 9, 10, 11, 15};
166         unsigned int i, irq, retval;
167         struct net_local *lp;
168
169         /* Resetting the chip doesn't reset the ISA interface, so don't bother.
170            That means we have to be careful with the register values we probe for.
171            */
172
173         if (!request_region(ioaddr, FMV18X_IO_EXTENT, dev->name))
174                 return -EBUSY;
175
176         /* Check I/O address configuration and Fujitsu vendor code */
177         if (inb(ioaddr+FJ_MACADDR  ) != 0x00
178         ||  inb(ioaddr+FJ_MACADDR+1) != 0x00
179         ||  inb(ioaddr+FJ_MACADDR+2) != 0x0e) {
180                 retval = -ENODEV;
181                 goto out;
182         }
183
184         /* Check PnP mode for FMV-183/184/183A/184A. */
185         /* This PnP routine is very poor. IO and IRQ should be known. */
186         if (inb(ioaddr + FJ_STATUS1) & 0x20) {
187                 irq = dev->irq;
188                 for (i = 0; i < 8; i++) {
189                         if (irq == irqmap_pnp[i])
190                                 break;
191                 }
192                 if (i == 8) {
193                         retval = -ENODEV;
194                         goto out;
195                 }
196         } else {
197                 if (fmv18x_probe_list[inb(ioaddr + FJ_CONFIG0) & 0x07] != ioaddr)
198                         return -ENODEV;
199                 irq = irqmap[(inb(ioaddr + FJ_CONFIG0)>>6) & 0x03];
200         }
201
202         /* Snarf the interrupt vector now. */
203         retval = request_irq(irq, &net_interrupt, 0, dev->name, dev);
204         if (retval) {
205                 printk ("FMV-18x found at %#3x, but it's unusable due to a conflict on"
206                                 "IRQ %d.\n", ioaddr, irq);
207                 goto out;
208         }
209
210         printk("%s: FMV-18x found at %#3x, IRQ %d, address ", dev->name,
211                    ioaddr, irq);
212
213         dev->base_addr = ioaddr;
214         dev->irq = irq;
215
216         for(i = 0; i < 6; i++) {
217                 unsigned char val = inb(ioaddr + FJ_MACADDR + i);
218                 printk("%02x", val);
219                 dev->dev_addr[i] = val;
220         }
221
222         /* "FJ_STATUS0" 12 bit 0x0400 means use regular 100 ohm 10baseT signals,
223            rather than 150 ohm shielded twisted pair compensation.
224            0x0000 == auto-sense the interface
225            0x0800 == use TP interface
226            0x1800 == use coax interface
227            */
228         {
229                 const char *porttype[] = {"auto-sense", "10baseT", "auto-sense", "10base2/5"};
230                 ushort setup_value = inb(ioaddr + FJ_STATUS0);
231
232                 switch( setup_value & 0x07 ){
233                 case 0x01 /* 10base5 */:
234                 case 0x02 /* 10base2 */: dev->if_port = 0x18; break;
235                 case 0x04 /* 10baseT */: dev->if_port = 0x08; break;
236                 default /* auto-sense*/: dev->if_port = 0x00; break;
237                 }
238                 printk(" %s interface.\n", porttype[(dev->if_port>>3) & 3]);
239         }
240
241         /* Initialize LAN Controller and LAN Card */
242         outb(0xda, ioaddr + CONFIG_0);   /* Initialize LAN Controller */
243         outb(0x00, ioaddr + CONFIG_1);   /* Stand by mode */
244         outb(0x00, ioaddr + FJ_CONFIG1); /* Disable IRQ of LAN Card */
245         outb(0x00, ioaddr + FJ_BUFCNTL); /* Reset ? I'm not sure (TAMIYA) */
246
247         /* wait for a while */
248         udelay(200);
249
250         /* Set the station address in bank zero. */
251         outb(0x00, ioaddr + CONFIG_1);
252         for (i = 0; i < 6; i++)
253                 outb(dev->dev_addr[i], ioaddr + 8 + i);
254
255         /* Switch to bank 1 and set the multicast table to accept none. */
256         outb(0x04, ioaddr + CONFIG_1);
257         for (i = 0; i < 8; i++)
258                 outb(0x00, ioaddr + 8 + i);
259
260         /* Switch to bank 2 and lock our I/O address. */
261         outb(0x08, ioaddr + CONFIG_1);
262         outb(dev->if_port, ioaddr + MODE13);
263         outb(0x00, ioaddr + COL16CNTL);
264
265         if (net_debug)
266                 printk(version);
267
268         /* Initialize the device structure. */
269         dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
270         if (!dev->priv) {
271                 retval = -ENOMEM;
272                 goto out_irq;
273         }
274         memset(dev->priv, 0, sizeof(struct net_local));
275         lp = dev->priv;
276         spin_lock_init(&lp->lock);
277
278         dev->open               = net_open;
279         dev->stop               = net_close;
280         dev->hard_start_xmit    = net_send_packet;
281         dev->tx_timeout         = net_timeout;
282         dev->watchdog_timeo     = HZ/10;
283         dev->get_stats          = net_get_stats;
284         dev->set_multicast_list = set_multicast_list;
285
286         /* Fill in the fields of 'dev' with ethernet-generic values. */
287
288         ether_setup(dev);
289         return 0;
290
291 out_irq:
292         free_irq(irq, dev);
293 out:
294         release_region(ioaddr, FMV18X_IO_EXTENT);
295         return retval;
296 }
297 \f
298
299 static int net_open(struct net_device *dev)
300 {
301         struct net_local *lp = dev->priv;
302         int ioaddr = dev->base_addr;
303
304         /* Set the configuration register 0 to 32K 100ns. byte-wide memory,
305            16 bit bus access, and two 4K Tx, enable the Rx and Tx. */
306         outb(0x5a, ioaddr + CONFIG_0);
307
308         /* Powerup and switch to register bank 2 for the run-time registers. */
309         outb(0xe8, ioaddr + CONFIG_1);
310
311         lp->tx_started = 0;
312         lp->tx_queue_ready = 1;
313         lp->rx_started = 0;
314         lp->tx_queue = 0;
315         lp->tx_queue_len = 0;
316
317         /* Clear Tx and Rx Status */
318         outb(0xff, ioaddr + TX_STATUS);
319         outb(0xff, ioaddr + RX_STATUS);
320         lp->open_time = jiffies;
321
322         netif_start_queue(dev);
323         
324         /* Enable the IRQ of the LAN Card */
325         outb(0x80, ioaddr + FJ_CONFIG1);
326
327         /* Enable both Tx and Rx interrupts */
328         outw(0x8182, ioaddr+TX_INTR);
329
330         return 0;
331 }
332
333 static void net_timeout(struct net_device *dev)
334 {
335         struct net_local *lp = dev->priv;
336         int ioaddr = dev->base_addr;
337         unsigned long flags;
338         
339         
340         printk(KERN_WARNING "%s: transmit timed out with status %04x, %s?\n", dev->name,
341                    htons(inw(ioaddr + TX_STATUS)),
342                    inb(ioaddr + TX_STATUS) & 0x80
343                    ? "IRQ conflict" : "network cable problem");
344         printk(KERN_WARNING "%s: timeout registers: %04x %04x %04x %04x %04x %04x %04x %04x.\n",
345                    dev->name, htons(inw(ioaddr + 0)),
346                    htons(inw(ioaddr + 2)), htons(inw(ioaddr + 4)),
347                    htons(inw(ioaddr + 6)), htons(inw(ioaddr + 8)),
348                    htons(inw(ioaddr +10)), htons(inw(ioaddr +12)),
349                    htons(inw(ioaddr +14)));
350         printk(KERN_WARNING "eth card: %04x %04x\n",
351                 htons(inw(ioaddr+FJ_STATUS0)),
352                 htons(inw(ioaddr+FJ_CONFIG0)));
353         lp->stats.tx_errors++;
354         /* ToDo: We should try to restart the adaptor... */
355         spin_lock_irqsave(&lp->lock, flags);
356
357         /* Initialize LAN Controller and LAN Card */
358         outb(0xda, ioaddr + CONFIG_0);   /* Initialize LAN Controller */
359         outb(0x00, ioaddr + CONFIG_1);   /* Stand by mode */
360         outb(0x00, ioaddr + FJ_CONFIG1); /* Disable IRQ of LAN Card */
361         outb(0x00, ioaddr + FJ_BUFCNTL); /* Reset ? I'm not sure */
362         net_open(dev);
363         spin_unlock_irqrestore(&lp->lock, flags);
364
365         netif_wake_queue(dev);
366 }
367
368 static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
369 {
370         struct net_local *lp = dev->priv;
371         int ioaddr = dev->base_addr;
372         short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
373         unsigned char *buf = skb->data;
374         unsigned long flags;
375
376         /* Block a transmit from overlapping.  */
377         
378         if (length > ETH_FRAME_LEN) {
379                 if (net_debug)
380                         printk("%s: Attempting to send a large packet (%d bytes).\n",
381                                 dev->name, length);
382                 return 1;
383         }
384         if (net_debug > 4)
385                 printk("%s: Transmitting a packet of length %lu.\n", dev->name,
386                            (unsigned long)skb->len);
387         /* We may not start transmitting unless we finish transferring
388            a packet into the Tx queue. During executing the following
389            codes we possibly catch a Tx interrupt. Thus we flag off
390            tx_queue_ready, so that we prevent the interrupt routine
391            (net_interrupt) to start transmitting. */
392         spin_lock_irqsave(&lp->lock, flags);
393         lp->tx_queue_ready = 0;
394         {
395                 outw(length, ioaddr + DATAPORT);
396                 outsw(ioaddr + DATAPORT, buf, (length + 1) >> 1);
397                 lp->tx_queue++;
398                 lp->tx_queue_len += length + 2;
399         }
400         lp->tx_queue_ready = 1;
401         spin_unlock_irqrestore(&lp->lock, flags);
402
403         if (lp->tx_started == 0) {
404                 /* If the Tx is idle, always trigger a transmit. */
405                 outb(0x80 | lp->tx_queue, ioaddr + TX_START);
406                 lp->tx_queue = 0;
407                 lp->tx_queue_len = 0;
408                 dev->trans_start = jiffies;
409                 lp->tx_started = 1;
410         } else if (lp->tx_queue_len < 4096 - 1502)
411                 /* Yes, there is room for one more packet. */
412         else
413                 netif_stop_queue(dev);
414
415         dev_kfree_skb(skb);
416         return 0;
417 }
418 \f
419 /* The typical workload of the driver:
420    Handle the network interface interrupts. */
421 static void
422 net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
423 {
424         struct net_device *dev = dev_id;
425         struct net_local *lp;
426         int ioaddr, status;
427
428         ioaddr = dev->base_addr;
429         lp = dev->priv;
430         status = inw(ioaddr + TX_STATUS);
431         outw(status, ioaddr + TX_STATUS);
432
433         if (net_debug > 4)
434                 printk("%s: Interrupt with status %04x.\n", dev->name, status);
435         if (lp->rx_started == 0 &&
436                 (status & 0xff00 || (inb(ioaddr + RX_MODE) & 0x40) == 0)) {
437                 /* Got a packet(s).
438                    We cannot execute net_rx more than once at the same time for
439                    the same device. During executing net_rx, we possibly catch a
440                    Tx interrupt. Thus we flag on rx_started, so that we prevent
441                    the interrupt routine (net_interrupt) to dive into net_rx
442                    again. */
443                 lp->rx_started = 1;
444                 outb(0x00, ioaddr + RX_INTR);   /* Disable RX intr. */
445                 net_rx(dev);
446                 outb(0x81, ioaddr + RX_INTR);   /* Enable  RX intr. */
447                 lp->rx_started = 0;
448         }
449         if (status & 0x00ff) {
450                 if (status & 0x02) {
451                         /* More than 16 collisions occurred */
452                         if (net_debug > 4)
453                                 printk("%s: 16 Collision occur during Txing.\n", dev->name);
454                         /* Cancel sending a packet. */
455                         outb(0x03, ioaddr + COL16CNTL);
456                         lp->stats.collisions++;
457                 }
458                 if (status & 0x82) {
459                         spin_lock(&lp->lock);
460                         lp->stats.tx_packets++;
461                         if (lp->tx_queue && lp->tx_queue_ready) {
462                                 outb(0x80 | lp->tx_queue, ioaddr + TX_START);
463                                 lp->tx_queue = 0;
464                                 lp->tx_queue_len = 0;
465                                 dev->trans_start = jiffies;
466                                 netif_wake_queue(dev);  /* Inform upper layers. */
467                         } else {
468                                 lp->tx_started = 0;
469                                 netif_wake_queue(dev);  /* Inform upper layers. */
470                         }
471                         spin_unlock(&lp->lock);
472                 }
473         }
474         return;
475 }
476
477 /* We have a good packet(s), get it/them out of the buffers. */
478 static void net_rx(struct net_device *dev)
479 {
480         struct net_local *lp = dev->priv;
481         int ioaddr = dev->base_addr;
482         int boguscount = 5;
483
484         while ((inb(ioaddr + RX_MODE) & 0x40) == 0) {
485                 /* Clear PKT_RDY bit: by agy 19940922 */
486                 /* outb(0x80, ioaddr + RX_STATUS); */
487                 ushort status = inw(ioaddr + DATAPORT);
488
489                 if (net_debug > 4)
490                         printk("%s: Rxing packet mode %02x status %04x.\n",
491                                    dev->name, inb(ioaddr + RX_MODE), status);
492 #ifndef final_version
493                 if (status == 0) {
494                         outb(0x05, ioaddr + 14);
495                         break;
496                 }
497 #endif
498
499                 if ((status & 0xF0) != 0x20) {  /* There was an error. */
500                         lp->stats.rx_errors++;
501                         if (status & 0x08) lp->stats.rx_length_errors++;
502                         if (status & 0x04) lp->stats.rx_frame_errors++;
503                         if (status & 0x02) lp->stats.rx_crc_errors++;
504                         if (status & 0x01) lp->stats.rx_over_errors++;
505                 } else {
506                         ushort pkt_len = inw(ioaddr + DATAPORT);
507                         /* Malloc up new buffer. */
508                         struct sk_buff *skb;
509
510                         if (pkt_len > 1550) {
511                                 printk("%s: The FMV-18x claimed a very large packet, size %d.\n",
512                                            dev->name, pkt_len);
513                                 outb(0x05, ioaddr + 14);
514                                 lp->stats.rx_errors++;
515                                 break;
516                         }
517                         skb = dev_alloc_skb(pkt_len+3);
518                         if (skb == NULL) {
519                                 printk("%s: Memory squeeze, dropping packet (len %d).\n",
520                                            dev->name, pkt_len);
521                                 outb(0x05, ioaddr + 14);
522                                 lp->stats.rx_dropped++;
523                                 break;
524                         }
525                         skb->dev = dev;
526                         skb_reserve(skb,2);
527
528                         insw(ioaddr + DATAPORT, skb_put(skb,pkt_len), (pkt_len + 1) >> 1);
529
530                         if (net_debug > 5) {
531                                 int i;
532                                 printk("%s: Rxed packet of length %d: ", dev->name, pkt_len);
533                                 for (i = 0; i < 14; i++)
534                                         printk(" %02x", skb->data[i]);
535                                 printk(".\n");
536                         }
537
538                         skb->protocol=eth_type_trans(skb, dev);
539                         netif_rx(skb);
540                         dev->last_rx = jiffies;
541                         lp->stats.rx_packets++;
542                         lp->stats.rx_bytes += pkt_len;
543                 }
544                 if (--boguscount <= 0)
545                         break;
546         }
547
548         /* If any worth-while packets have been received, dev_rint()
549            has done a mark_bh(NET_BH) for us and will work on them
550            when we get to the bottom-half routine. */
551         {
552                 int i;
553                 for (i = 0; i < 20; i++) {
554                         if ((inb(ioaddr + RX_MODE) & 0x40) == 0x40)
555                                 break;
556                         (void)inw(ioaddr + DATAPORT);                           /* dummy status read */
557                         outb(0x05, ioaddr + 14);
558                 }
559
560                 if (net_debug > 5 && i > 0)
561                         printk("%s: Exint Rx packet with mode %02x after %d ticks.\n",
562                                    dev->name, inb(ioaddr + RX_MODE), i);
563         }
564
565         return;
566 }
567
568 /* The inverse routine to net_open(). */
569 static int net_close(struct net_device *dev)
570 {
571         int ioaddr = dev->base_addr;
572
573         ((struct net_local *)dev->priv)->open_time = 0;
574
575         netif_stop_queue(dev);
576         
577         /* Set configuration register 0 to disable Tx and Rx. */
578         outb(0xda, ioaddr + CONFIG_0);
579
580         /* Update the statistics -- ToDo. */
581
582         /* Power-down the chip.  Green, green, green! */
583         outb(0x00, ioaddr + CONFIG_1);
584
585         /* Set the ethernet adaptor disable IRQ */
586         outb(0x00, ioaddr + FJ_CONFIG1);
587
588         return 0;
589 }
590
591 /* Get the current statistics.  This may be called with the card open or
592    closed. */
593 static struct net_device_stats *net_get_stats(struct net_device *dev)
594 {
595         struct net_local *lp = dev->priv;
596         return &lp->stats;
597 }
598
599 /* Set or clear the multicast filter for this adaptor.
600    num_addrs == -1      Promiscuous mode, receive all packets
601    num_addrs == 0       Normal mode, clear multicast list
602    num_addrs > 0        Multicast mode, receive normal and MC packets, and do
603                         best-effort filtering.
604  */
605  
606 static void set_multicast_list(struct net_device *dev)
607 {
608         short ioaddr = dev->base_addr;
609         if (dev->mc_count || dev->flags&(IFF_PROMISC|IFF_ALLMULTI))
610         {
611                 /*
612                  *      We must make the kernel realise we had to move
613                  *      into promisc mode or we start all out war on
614                  *      the cable. - AC
615                  */
616                 dev->flags|=IFF_PROMISC;
617
618                 outb(3, ioaddr + RX_MODE);      /* Enable promiscuous mode */
619         }
620         else
621                 outb(2, ioaddr + RX_MODE);      /* Disable promiscuous, use normal mode */
622 }
623
624 #ifdef MODULE
625 static struct net_device dev_fmv18x;
626 static int io = 0x220;
627 static int irq;
628
629 MODULE_PARM(io, "i");
630 MODULE_PARM(irq, "i");
631 MODULE_PARM(net_debug, "i");
632 MODULE_PARM_DESC(io, "FMV-18X I/O address");
633 MODULE_PARM_DESC(irq, "FMV-18X IRQ number");
634 MODULE_PARM_DESC(net_debug, "FMV-18X debug level (0-1,5-6)");
635 MODULE_LICENSE("GPL");
636
637 int init_module(void)
638 {
639         if (io == 0)
640                 printk("fmv18x: You should not use auto-probing with insmod!\n");
641         dev_fmv18x.base_addr    = io;
642         dev_fmv18x.irq          = irq;
643         dev_fmv18x.init         = fmv18x_probe;
644         if (register_netdev(&dev_fmv18x) != 0) {
645                 printk("fmv18x: register_netdev() returned non-zero.\n");
646                 return -EIO;
647         }
648         return 0;
649 }
650
651 void
652 cleanup_module(void)
653 {
654         unregister_netdev(&dev_fmv18x);
655         kfree(dev_fmv18x.priv);
656         dev_fmv18x.priv = NULL;
657
658         /* If we don't do this, we can't re-insmod it later. */
659         free_irq(dev_fmv18x.irq, &dev_fmv18x);
660         release_region(dev_fmv18x.base_addr, FMV18X_IO_EXTENT);
661 }
662 #endif /* MODULE */
663 \f
664 /*
665  * Local variables:
666  *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c fmv18x.c"
667  *  version-control: t
668  *  kept-new-versions: 5
669  *  tab-width: 4
670  *  c-indent-level: 4
671  * End:
672  */