Merge with Linux 2.5.59.
[linux-2.6/linux-mips.git] / drivers / net / smc9194.c
blobb66915f147eb13c62327f0006a165102aae95f57
1 /*------------------------------------------------------------------------
2 . smc9194.c
3 . This is a driver for SMC's 9000 series of Ethernet cards.
5 . Copyright (C) 1996 by Erik Stahlman
6 . This software may be used and distributed according to the terms
7 . of the GNU General Public License, incorporated herein by reference.
9 . "Features" of the SMC chip:
10 . 4608 byte packet memory. ( for the 91C92. Others have more )
11 . EEPROM for configuration
12 . AUI/TP selection ( mine has 10Base2/10BaseT select )
14 . Arguments:
15 . io = for the base address
16 . irq = for the IRQ
17 . ifport = 0 for autodetect, 1 for TP, 2 for AUI ( or 10base2 )
19 . author:
20 . Erik Stahlman ( erik@vt.edu )
21 . contributors:
22 . Arnaldo Carvalho de Melo <acme@conectiva.com.br>
24 . Hardware multicast code from Peter Cammaert ( pc@denkart.be )
26 . Sources:
27 . o SMC databook
28 . o skeleton.c by Donald Becker ( becker@scyld.com )
29 . o ( a LOT of advice from Becker as well )
31 . History:
32 . 12/07/95 Erik Stahlman written, got receive/xmit handled
33 . 01/03/96 Erik Stahlman worked out some bugs, actually usable!!! :-)
34 . 01/06/96 Erik Stahlman cleaned up some, better testing, etc
35 . 01/29/96 Erik Stahlman fixed autoirq, added multicast
36 . 02/01/96 Erik Stahlman 1. disabled all interrupts in smc_reset
37 . 2. got rid of post-decrementing bug -- UGH.
38 . 02/13/96 Erik Stahlman Tried to fix autoirq failure. Added more
39 . descriptive error messages.
40 . 02/15/96 Erik Stahlman Fixed typo that caused detection failure
41 . 02/23/96 Erik Stahlman Modified it to fit into kernel tree
42 . Added support to change hardware address
43 . Cleared stats on opens
44 . 02/26/96 Erik Stahlman Trial support for Kernel 1.2.13
45 . Kludge for automatic IRQ detection
46 . 03/04/96 Erik Stahlman Fixed kernel 1.3.70 +
47 . Fixed bug reported by Gardner Buchanan in
48 . smc_enable, with outw instead of outb
49 . 03/06/96 Erik Stahlman Added hardware multicast from Peter Cammaert
50 . 04/14/00 Heiko Pruessing (SMA Regelsysteme) Fixed bug in chip memory
51 . allocation
52 . 08/20/00 Arnaldo Melo fix kfree(skb) in smc_hardware_send_packet
53 . 12/15/00 Christian Jullien fix "Warning: kfree_skb on hard IRQ"
54 . 11/08/01 Matt Domsch Use common crc32 function
55 ----------------------------------------------------------------------------*/
57 static const char version[] =
58 "smc9194.c:v0.14 12/15/00 by Erik Stahlman (erik@vt.edu)\n";
60 #include <linux/module.h>
61 #include <linux/version.h>
62 #include <linux/kernel.h>
63 #include <linux/types.h>
64 #include <linux/fcntl.h>
65 #include <linux/interrupt.h>
66 #include <linux/ioport.h>
67 #include <linux/in.h>
68 #include <linux/slab.h>
69 #include <linux/string.h>
70 #include <linux/init.h>
71 #include <linux/crc32.h>
72 #include <linux/errno.h>
73 #include <linux/netdevice.h>
74 #include <linux/etherdevice.h>
75 #include <linux/skbuff.h>
77 #include <asm/bitops.h>
78 #include <asm/io.h>
80 #include "smc9194.h"
82 /*------------------------------------------------------------------------
84 . Configuration options, for the experienced user to change.
86 -------------------------------------------------------------------------*/
89 . Do you want to use 32 bit xfers? This should work on all chips, as
90 . the chipset is designed to accommodate them.
92 #ifdef __sh__
93 #undef USE_32_BIT
94 #else
95 #define USE_32_BIT 1
96 #endif
99 .the SMC9194 can be at any of the following port addresses. To change,
100 .for a slightly different card, you can add it to the array. Keep in
101 .mind that the array must end in zero.
103 static unsigned int smc_portlist[] __initdata = {
104 0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0,
105 0x300, 0x320, 0x340, 0x360, 0x380, 0x3A0, 0x3C0, 0x3E0, 0
109 . Wait time for memory to be free. This probably shouldn't be
110 . tuned that much, as waiting for this means nothing else happens
111 . in the system
113 #define MEMORY_WAIT_TIME 16
116 . DEBUGGING LEVELS
118 . 0 for normal operation
119 . 1 for slightly more details
120 . >2 for various levels of increasingly useless information
121 . 2 for interrupt tracking, status flags
122 . 3 for packet dumps, etc.
124 #define SMC_DEBUG 0
126 #if (SMC_DEBUG > 2 )
127 #define PRINTK3(x) printk x
128 #else
129 #define PRINTK3(x)
130 #endif
132 #if SMC_DEBUG > 1
133 #define PRINTK2(x) printk x
134 #else
135 #define PRINTK2(x)
136 #endif
138 #ifdef SMC_DEBUG
139 #define PRINTK(x) printk x
140 #else
141 #define PRINTK(x)
142 #endif
145 /*------------------------------------------------------------------------
147 . The internal workings of the driver. If you are changing anything
148 . here with the SMC stuff, you should have the datasheet and known
149 . what you are doing.
151 -------------------------------------------------------------------------*/
152 #define CARDNAME "SMC9194"
155 /* store this information for the driver.. */
156 struct smc_local {
158 these are things that the kernel wants me to keep, so users
159 can find out semi-useless statistics of how well the card is
160 performing
162 struct net_device_stats stats;
165 If I have to wait until memory is available to send
166 a packet, I will store the skbuff here, until I get the
167 desired memory. Then, I'll send it out and free it.
169 struct sk_buff * saved_skb;
172 . This keeps track of how many packets that I have
173 . sent out. When an TX_EMPTY interrupt comes, I know
174 . that all of these have been sent.
176 int packets_waiting;
180 /*-----------------------------------------------------------------
182 . The driver can be entered at any of the following entry points.
184 .------------------------------------------------------------------ */
187 . This is called by register_netdev(). It is responsible for
188 . checking the portlist for the SMC9000 series chipset. If it finds
189 . one, then it will initialize the device, find the hardware information,
190 . and sets up the appropriate device parameters.
191 . NOTE: Interrupts are *OFF* when this procedure is called.
193 . NB:This shouldn't be static since it is referred to externally.
195 int smc_init(struct net_device *dev);
198 . The kernel calls this function when someone wants to use the device,
199 . typically 'ifconfig ethX up'.
201 static int smc_open(struct net_device *dev);
204 . Our watchdog timed out. Called by the networking layer
206 static void smc_timeout(struct net_device *dev);
209 . This is called by the kernel in response to 'ifconfig ethX down'. It
210 . is responsible for cleaning up everything that the open routine
211 . does, and maybe putting the card into a powerdown state.
213 static int smc_close(struct net_device *dev);
216 . This routine allows the proc file system to query the driver's
217 . statistics.
219 static struct net_device_stats * smc_query_statistics( struct net_device *dev);
222 . Finally, a call to set promiscuous mode ( for TCPDUMP and related
223 . programs ) and multicast modes.
225 static void smc_set_multicast_list(struct net_device *dev);
228 /*---------------------------------------------------------------
230 . Interrupt level calls..
232 ----------------------------------------------------------------*/
235 . Handles the actual interrupt
237 static void smc_interrupt(int irq, void *, struct pt_regs *regs);
239 . This is a separate procedure to handle the receipt of a packet, to
240 . leave the interrupt code looking slightly cleaner
242 static inline void smc_rcv( struct net_device *dev );
244 . This handles a TX interrupt, which is only called when an error
245 . relating to a packet is sent.
247 static inline void smc_tx( struct net_device * dev );
250 ------------------------------------------------------------
252 . Internal routines
254 ------------------------------------------------------------
258 . Test if a given location contains a chip, trying to cause as
259 . little damage as possible if it's not a SMC chip.
261 static int smc_probe(struct net_device *dev, int ioaddr);
264 . A rather simple routine to print out a packet for debugging purposes.
266 #if SMC_DEBUG > 2
267 static void print_packet( byte *, int );
268 #endif
270 #define tx_done(dev) 1
272 /* this is called to actually send the packet to the chip */
273 static void smc_hardware_send_packet( struct net_device * dev );
275 /* Since I am not sure if I will have enough room in the chip's ram
276 . to store the packet, I call this routine, which either sends it
277 . now, or generates an interrupt when the card is ready for the
278 . packet */
279 static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device *dev );
281 /* this does a soft reset on the device */
282 static void smc_reset( int ioaddr );
284 /* Enable Interrupts, Receive, and Transmit */
285 static void smc_enable( int ioaddr );
287 /* this puts the device in an inactive state */
288 static void smc_shutdown( int ioaddr );
290 /* This routine will find the IRQ of the driver if one is not
291 . specified in the input to the device. */
292 static int smc_findirq( int ioaddr );
295 . Function: smc_reset( int ioaddr )
296 . Purpose:
297 . This sets the SMC91xx chip to its normal state, hopefully from whatever
298 . mess that any other DOS driver has put it in.
300 . Maybe I should reset more registers to defaults in here? SOFTRESET should
301 . do that for me.
303 . Method:
304 . 1. send a SOFT RESET
305 . 2. wait for it to finish
306 . 3. enable autorelease mode
307 . 4. reset the memory management unit
308 . 5. clear all interrupts
311 static void smc_reset( int ioaddr )
313 /* This resets the registers mostly to defaults, but doesn't
314 affect EEPROM. That seems unnecessary */
315 SMC_SELECT_BANK( 0 );
316 outw( RCR_SOFTRESET, ioaddr + RCR );
318 /* this should pause enough for the chip to be happy */
319 SMC_DELAY( );
321 /* Set the transmit and receive configuration registers to
322 default values */
323 outw( RCR_CLEAR, ioaddr + RCR );
324 outw( TCR_CLEAR, ioaddr + TCR );
326 /* set the control register to automatically
327 release successfully transmitted packets, to make the best
328 use out of our limited memory */
329 SMC_SELECT_BANK( 1 );
330 outw( inw( ioaddr + CONTROL ) | CTL_AUTO_RELEASE , ioaddr + CONTROL );
332 /* Reset the MMU */
333 SMC_SELECT_BANK( 2 );
334 outw( MC_RESET, ioaddr + MMU_CMD );
336 /* Note: It doesn't seem that waiting for the MMU busy is needed here,
337 but this is a place where future chipsets _COULD_ break. Be wary
338 of issuing another MMU command right after this */
340 outb( 0, ioaddr + INT_MASK );
344 . Function: smc_enable
345 . Purpose: let the chip talk to the outside work
346 . Method:
347 . 1. Enable the transmitter
348 . 2. Enable the receiver
349 . 3. Enable interrupts
351 static void smc_enable( int ioaddr )
353 SMC_SELECT_BANK( 0 );
354 /* see the header file for options in TCR/RCR NORMAL*/
355 outw( TCR_NORMAL, ioaddr + TCR );
356 outw( RCR_NORMAL, ioaddr + RCR );
358 /* now, enable interrupts */
359 SMC_SELECT_BANK( 2 );
360 outb( SMC_INTERRUPT_MASK, ioaddr + INT_MASK );
364 . Function: smc_shutdown
365 . Purpose: closes down the SMC91xxx chip.
366 . Method:
367 . 1. zero the interrupt mask
368 . 2. clear the enable receive flag
369 . 3. clear the enable xmit flags
371 . TODO:
372 . (1) maybe utilize power down mode.
373 . Why not yet? Because while the chip will go into power down mode,
374 . the manual says that it will wake up in response to any I/O requests
375 . in the register space. Empirical results do not show this working.
377 static void smc_shutdown( int ioaddr )
379 /* no more interrupts for me */
380 SMC_SELECT_BANK( 2 );
381 outb( 0, ioaddr + INT_MASK );
383 /* and tell the card to stay away from that nasty outside world */
384 SMC_SELECT_BANK( 0 );
385 outb( RCR_CLEAR, ioaddr + RCR );
386 outb( TCR_CLEAR, ioaddr + TCR );
387 #if 0
388 /* finally, shut the chip down */
389 SMC_SELECT_BANK( 1 );
390 outw( inw( ioaddr + CONTROL ), CTL_POWERDOWN, ioaddr + CONTROL );
391 #endif
396 . Function: smc_setmulticast( int ioaddr, int count, dev_mc_list * adds )
397 . Purpose:
398 . This sets the internal hardware table to filter out unwanted multicast
399 . packets before they take up memory.
401 . The SMC chip uses a hash table where the high 6 bits of the CRC of
402 . address are the offset into the table. If that bit is 1, then the
403 . multicast packet is accepted. Otherwise, it's dropped silently.
405 . To use the 6 bits as an offset into the table, the high 3 bits are the
406 . number of the 8 bit register, while the low 3 bits are the bit within
407 . that register.
409 . This routine is based very heavily on the one provided by Peter Cammaert.
413 static void smc_setmulticast( int ioaddr, int count, struct dev_mc_list * addrs ) {
414 int i;
415 unsigned char multicast_table[ 8 ];
416 struct dev_mc_list * cur_addr;
417 /* table for flipping the order of 3 bits */
418 unsigned char invert3[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
420 /* start with a table of all zeros: reject all */
421 memset( multicast_table, 0, sizeof( multicast_table ) );
423 cur_addr = addrs;
424 for ( i = 0; i < count ; i ++, cur_addr = cur_addr->next ) {
425 int position;
427 /* do we have a pointer here? */
428 if ( !cur_addr )
429 break;
430 /* make sure this is a multicast address - shouldn't this
431 be a given if we have it here ? */
432 if ( !( *cur_addr->dmi_addr & 1 ) )
433 continue;
435 /* only use the low order bits */
436 position = ether_crc_le(6, cur_addr->dmi_addr) & 0x3f;
438 /* do some messy swapping to put the bit in the right spot */
439 multicast_table[invert3[position&7]] |=
440 (1<<invert3[(position>>3)&7]);
443 /* now, the table can be loaded into the chipset */
444 SMC_SELECT_BANK( 3 );
446 for ( i = 0; i < 8 ; i++ ) {
447 outb( multicast_table[i], ioaddr + MULTICAST1 + i );
452 . Function: smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * )
453 . Purpose:
454 . Attempt to allocate memory for a packet, if chip-memory is not
455 . available, then tell the card to generate an interrupt when it
456 . is available.
458 . Algorithm:
460 . o if the saved_skb is not currently null, then drop this packet
461 . on the floor. This should never happen, because of TBUSY.
462 . o if the saved_skb is null, then replace it with the current packet,
463 . o See if I can sending it now.
464 . o (NO): Enable interrupts and let the interrupt handler deal with it.
465 . o (YES):Send it now.
467 static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * dev )
469 struct smc_local *lp = (struct smc_local *)dev->priv;
470 unsigned short ioaddr = dev->base_addr;
471 word length;
472 unsigned short numPages;
473 word time_out;
475 netif_stop_queue(dev);
476 /* Well, I want to send the packet.. but I don't know
477 if I can send it right now... */
479 if ( lp->saved_skb) {
480 /* THIS SHOULD NEVER HAPPEN. */
481 lp->stats.tx_aborted_errors++;
482 printk(CARDNAME": Bad Craziness - sent packet while busy.\n" );
483 return 1;
485 lp->saved_skb = skb;
487 length = skb->len;
489 if (length < ETH_ZLEN) {
490 skb = skb_padto(skb, ETH_ZLEN);
491 if (skb == NULL) {
492 netif_wake_queue(dev);
493 return 0;
495 length = ETH_ZLEN;
499 ** The MMU wants the number of pages to be the number of 256 bytes
500 ** 'pages', minus 1 ( since a packet can't ever have 0 pages :) )
502 ** Pkt size for allocating is data length +6 (for additional status words,
503 ** length and ctl!) If odd size last byte is included in this header.
505 numPages = ((length & 0xfffe) + 6) / 256;
507 if (numPages > 7 ) {
508 printk(CARDNAME": Far too big packet error. \n");
509 /* freeing the packet is a good thing here... but should
510 . any packets of this size get down here? */
511 dev_kfree_skb (skb);
512 lp->saved_skb = NULL;
513 /* this IS an error, but, i don't want the skb saved */
514 netif_wake_queue(dev);
515 return 0;
517 /* either way, a packet is waiting now */
518 lp->packets_waiting++;
520 /* now, try to allocate the memory */
521 SMC_SELECT_BANK( 2 );
522 outw( MC_ALLOC | numPages, ioaddr + MMU_CMD );
524 . Performance Hack
526 . wait a short amount of time.. if I can send a packet now, I send
527 . it now. Otherwise, I enable an interrupt and wait for one to be
528 . available.
530 . I could have handled this a slightly different way, by checking to
531 . see if any memory was available in the FREE MEMORY register. However,
532 . either way, I need to generate an allocation, and the allocation works
533 . no matter what, so I saw no point in checking free memory.
535 time_out = MEMORY_WAIT_TIME;
536 do {
537 word status;
539 status = inb( ioaddr + INTERRUPT );
540 if ( status & IM_ALLOC_INT ) {
541 /* acknowledge the interrupt */
542 outb( IM_ALLOC_INT, ioaddr + INTERRUPT );
543 break;
545 } while ( -- time_out );
547 if ( !time_out ) {
548 /* oh well, wait until the chip finds memory later */
549 SMC_ENABLE_INT( IM_ALLOC_INT );
550 PRINTK2((CARDNAME": memory allocation deferred. \n"));
551 /* it's deferred, but I'll handle it later */
552 return 0;
554 /* or YES! I can send the packet now.. */
555 smc_hardware_send_packet(dev);
556 netif_wake_queue(dev);
557 return 0;
561 . Function: smc_hardware_send_packet(struct net_device * )
562 . Purpose:
563 . This sends the actual packet to the SMC9xxx chip.
565 . Algorithm:
566 . First, see if a saved_skb is available.
567 . ( this should NOT be called if there is no 'saved_skb'
568 . Now, find the packet number that the chip allocated
569 . Point the data pointers at it in memory
570 . Set the length word in the chip's memory
571 . Dump the packet to chip memory
572 . Check if a last byte is needed ( odd length packet )
573 . if so, set the control flag right
574 . Tell the card to send it
575 . Enable the transmit interrupt, so I know if it failed
576 . Free the kernel data if I actually sent it.
578 static void smc_hardware_send_packet( struct net_device * dev )
580 struct smc_local *lp = (struct smc_local *)dev->priv;
581 byte packet_no;
582 struct sk_buff * skb = lp->saved_skb;
583 word length;
584 unsigned short ioaddr;
585 byte * buf;
587 ioaddr = dev->base_addr;
589 if ( !skb ) {
590 PRINTK((CARDNAME": In XMIT with no packet to send \n"));
591 return;
593 length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
594 buf = skb->data;
596 /* If I get here, I _know_ there is a packet slot waiting for me */
597 packet_no = inb( ioaddr + PNR_ARR + 1 );
598 if ( packet_no & 0x80 ) {
599 /* or isn't there? BAD CHIP! */
600 printk(KERN_DEBUG CARDNAME": Memory allocation failed. \n");
601 dev_kfree_skb_any(skb);
602 lp->saved_skb = NULL;
603 netif_wake_queue(dev);
604 return;
607 /* we have a packet address, so tell the card to use it */
608 outb( packet_no, ioaddr + PNR_ARR );
610 /* point to the beginning of the packet */
611 outw( PTR_AUTOINC , ioaddr + POINTER );
613 PRINTK3((CARDNAME": Trying to xmit packet of length %x\n", length ));
614 #if SMC_DEBUG > 2
615 print_packet( buf, length );
616 #endif
618 /* send the packet length ( +6 for status, length and ctl byte )
619 and the status word ( set to zeros ) */
620 #ifdef USE_32_BIT
621 outl( (length +6 ) << 16 , ioaddr + DATA_1 );
622 #else
623 outw( 0, ioaddr + DATA_1 );
624 /* send the packet length ( +6 for status words, length, and ctl*/
625 outb( (length+6) & 0xFF,ioaddr + DATA_1 );
626 outb( (length+6) >> 8 , ioaddr + DATA_1 );
627 #endif
629 /* send the actual data
630 . I _think_ it's faster to send the longs first, and then
631 . mop up by sending the last word. It depends heavily
632 . on alignment, at least on the 486. Maybe it would be
633 . a good idea to check which is optimal? But that could take
634 . almost as much time as is saved?
636 #ifdef USE_32_BIT
637 if ( length & 0x2 ) {
638 outsl(ioaddr + DATA_1, buf, length >> 2 );
639 outw( *((word *)(buf + (length & 0xFFFFFFFC))),ioaddr +DATA_1);
641 else
642 outsl(ioaddr + DATA_1, buf, length >> 2 );
643 #else
644 outsw(ioaddr + DATA_1 , buf, (length ) >> 1);
645 #endif
646 /* Send the last byte, if there is one. */
648 if ( (length & 1) == 0 ) {
649 outw( 0, ioaddr + DATA_1 );
650 } else {
651 outb( buf[length -1 ], ioaddr + DATA_1 );
652 outb( 0x20, ioaddr + DATA_1);
655 /* enable the interrupts */
656 SMC_ENABLE_INT( (IM_TX_INT | IM_TX_EMPTY_INT) );
658 /* and let the chipset deal with it */
659 outw( MC_ENQUEUE , ioaddr + MMU_CMD );
661 PRINTK2((CARDNAME": Sent packet of length %d \n",length));
663 lp->saved_skb = NULL;
664 dev_kfree_skb_any (skb);
666 dev->trans_start = jiffies;
668 /* we can send another packet */
669 netif_wake_queue(dev);
671 return;
674 /*-------------------------------------------------------------------------
676 | smc_init( struct net_device * dev )
677 | Input parameters:
678 | dev->base_addr == 0, try to find all possible locations
679 | dev->base_addr == 1, return failure code
680 | dev->base_addr == 2, always allocate space, and return success
681 | dev->base_addr == <anything else> this is the address to check
683 | Output:
684 | 0 --> there is a device
685 | anything else, error
687 ---------------------------------------------------------------------------
689 int __init smc_init(struct net_device *dev)
691 int i;
692 int base_addr = dev->base_addr;
694 SET_MODULE_OWNER(dev);
696 /* try a specific location */
697 if (base_addr > 0x1ff)
698 return smc_probe(dev, base_addr);
699 else if (base_addr != 0)
700 return -ENXIO;
702 /* check every ethernet address */
703 for (i = 0; smc_portlist[i]; i++)
704 if (smc_probe(dev, smc_portlist[i]) == 0)
705 return 0;
707 /* couldn't find anything */
708 return -ENODEV;
711 /*----------------------------------------------------------------------
712 . smc_findirq
714 . This routine has a simple purpose -- make the SMC chip generate an
715 . interrupt, so an auto-detect routine can detect it, and find the IRQ,
716 ------------------------------------------------------------------------
718 int __init smc_findirq( int ioaddr )
720 int timeout = 20;
721 unsigned long cookie;
724 cookie = probe_irq_on();
727 * What I try to do here is trigger an ALLOC_INT. This is done
728 * by allocating a small chunk of memory, which will give an interrupt
729 * when done.
733 SMC_SELECT_BANK(2);
734 /* enable ALLOCation interrupts ONLY */
735 outb( IM_ALLOC_INT, ioaddr + INT_MASK );
738 . Allocate 512 bytes of memory. Note that the chip was just
739 . reset so all the memory is available
741 outw( MC_ALLOC | 1, ioaddr + MMU_CMD );
744 . Wait until positive that the interrupt has been generated
746 while ( timeout ) {
747 byte int_status;
749 int_status = inb( ioaddr + INTERRUPT );
751 if ( int_status & IM_ALLOC_INT )
752 break; /* got the interrupt */
753 timeout--;
755 /* there is really nothing that I can do here if timeout fails,
756 as probe_irq_off will return a 0 anyway, which is what I
757 want in this case. Plus, the clean up is needed in both
758 cases. */
760 /* DELAY HERE!
761 On a fast machine, the status might change before the interrupt
762 is given to the processor. This means that the interrupt was
763 never detected, and probe_irq_off fails to report anything.
764 This should fix probe_irq_* problems.
766 SMC_DELAY();
767 SMC_DELAY();
769 /* and disable all interrupts again */
770 outb( 0, ioaddr + INT_MASK );
772 /* and return what I found */
773 return probe_irq_off(cookie);
776 /*----------------------------------------------------------------------
777 . Function: smc_probe( int ioaddr )
779 . Purpose:
780 . Tests to see if a given ioaddr points to an SMC9xxx chip.
781 . Returns a 0 on success
783 . Algorithm:
784 . (1) see if the high byte of BANK_SELECT is 0x33
785 . (2) compare the ioaddr with the base register's address
786 . (3) see if I recognize the chip ID in the appropriate register
788 .---------------------------------------------------------------------
791 /*---------------------------------------------------------------
792 . Here I do typical initialization tasks.
794 . o Initialize the structure if needed
795 . o print out my vanity message if not done so already
796 . o print out what type of hardware is detected
797 . o print out the ethernet address
798 . o find the IRQ
799 . o set up my private data
800 . o configure the dev structure with my subroutines
801 . o actually GRAB the irq.
802 . o GRAB the region
803 .-----------------------------------------------------------------
805 static int __init smc_probe(struct net_device *dev, int ioaddr)
807 int i, memory, retval;
808 static unsigned version_printed;
809 unsigned int bank;
811 const char *version_string;
812 const char *if_string;
814 /* registers */
815 word revision_register;
816 word base_address_register;
817 word configuration_register;
818 word memory_info_register;
819 word memory_cfg_register;
821 /* Grab the region so that no one else tries to probe our ioports. */
822 if (!request_region(ioaddr, SMC_IO_EXTENT, dev->name))
823 return -EBUSY;
825 /* First, see if the high byte is 0x33 */
826 bank = inw( ioaddr + BANK_SELECT );
827 if ( (bank & 0xFF00) != 0x3300 ) {
828 retval = -ENODEV;
829 goto err_out;
831 /* The above MIGHT indicate a device, but I need to write to further
832 test this. */
833 outw( 0x0, ioaddr + BANK_SELECT );
834 bank = inw( ioaddr + BANK_SELECT );
835 if ( (bank & 0xFF00 ) != 0x3300 ) {
836 retval = -ENODEV;
837 goto err_out;
839 /* well, we've already written once, so hopefully another time won't
840 hurt. This time, I need to switch the bank register to bank 1,
841 so I can access the base address register */
842 SMC_SELECT_BANK(1);
843 base_address_register = inw( ioaddr + BASE );
844 if ( ioaddr != ( base_address_register >> 3 & 0x3E0 ) ) {
845 printk(CARDNAME ": IOADDR %x doesn't match configuration (%x)."
846 "Probably not a SMC chip\n",
847 ioaddr, base_address_register >> 3 & 0x3E0 );
848 /* well, the base address register didn't match. Must not have
849 been a SMC chip after all. */
850 retval = -ENODEV;
851 goto err_out;
854 /* check if the revision register is something that I recognize.
855 These might need to be added to later, as future revisions
856 could be added. */
857 SMC_SELECT_BANK(3);
858 revision_register = inw( ioaddr + REVISION );
859 if ( !chip_ids[ ( revision_register >> 4 ) & 0xF ] ) {
860 /* I don't recognize this chip, so... */
861 printk(CARDNAME ": IO %x: Unrecognized revision register:"
862 " %x, Contact author. \n", ioaddr, revision_register );
864 retval = -ENODEV;
865 goto err_out;
868 /* at this point I'll assume that the chip is an SMC9xxx.
869 It might be prudent to check a listing of MAC addresses
870 against the hardware address, or do some other tests. */
872 if (version_printed++ == 0)
873 printk("%s", version);
875 /* fill in some of the fields */
876 dev->base_addr = ioaddr;
879 . Get the MAC address ( bank 1, regs 4 - 9 )
881 SMC_SELECT_BANK( 1 );
882 for ( i = 0; i < 6; i += 2 ) {
883 word address;
885 address = inw( ioaddr + ADDR0 + i );
886 dev->dev_addr[ i + 1] = address >> 8;
887 dev->dev_addr[ i ] = address & 0xFF;
890 /* get the memory information */
892 SMC_SELECT_BANK( 0 );
893 memory_info_register = inw( ioaddr + MIR );
894 memory_cfg_register = inw( ioaddr + MCR );
895 memory = ( memory_cfg_register >> 9 ) & 0x7; /* multiplier */
896 memory *= 256 * ( memory_info_register & 0xFF );
899 Now, I want to find out more about the chip. This is sort of
900 redundant, but it's cleaner to have it in both, rather than having
901 one VERY long probe procedure.
903 SMC_SELECT_BANK(3);
904 revision_register = inw( ioaddr + REVISION );
905 version_string = chip_ids[ ( revision_register >> 4 ) & 0xF ];
906 if ( !version_string ) {
907 /* I shouldn't get here because this call was done before.... */
908 retval = -ENODEV;
909 goto err_out;
912 /* is it using AUI or 10BaseT ? */
913 if ( dev->if_port == 0 ) {
914 SMC_SELECT_BANK(1);
915 configuration_register = inw( ioaddr + CONFIG );
916 if ( configuration_register & CFG_AUI_SELECT )
917 dev->if_port = 2;
918 else
919 dev->if_port = 1;
921 if_string = interfaces[ dev->if_port - 1 ];
923 /* now, reset the chip, and put it into a known state */
924 smc_reset( ioaddr );
927 . If dev->irq is 0, then the device has to be banged on to see
928 . what the IRQ is.
930 . This banging doesn't always detect the IRQ, for unknown reasons.
931 . a workaround is to reset the chip and try again.
933 . Interestingly, the DOS packet driver *SETS* the IRQ on the card to
934 . be what is requested on the command line. I don't do that, mostly
935 . because the card that I have uses a non-standard method of accessing
936 . the IRQs, and because this _should_ work in most configurations.
938 . Specifying an IRQ is done with the assumption that the user knows
939 . what (s)he is doing. No checking is done!!!!
942 if ( dev->irq < 2 ) {
943 int trials;
945 trials = 3;
946 while ( trials-- ) {
947 dev->irq = smc_findirq( ioaddr );
948 if ( dev->irq )
949 break;
950 /* kick the card and try again */
951 smc_reset( ioaddr );
954 if (dev->irq == 0 ) {
955 printk(CARDNAME": Couldn't autodetect your IRQ. Use irq=xx.\n");
956 retval = -ENODEV;
957 goto err_out;
960 /* now, print out the card info, in a short format.. */
962 printk("%s: %s(r:%d) at %#3x IRQ:%d INTF:%s MEM:%db ", dev->name,
963 version_string, revision_register & 0xF, ioaddr, dev->irq,
964 if_string, memory );
966 . Print the Ethernet address
968 printk("ADDR: ");
969 for (i = 0; i < 5; i++)
970 printk("%2.2x:", dev->dev_addr[i] );
971 printk("%2.2x \n", dev->dev_addr[5] );
974 /* Initialize the private structure. */
975 if (dev->priv == NULL) {
976 dev->priv = kmalloc(sizeof(struct smc_local), GFP_KERNEL);
977 if (dev->priv == NULL) {
978 retval = -ENOMEM;
979 goto err_out;
982 /* set the private data to zero by default */
983 memset(dev->priv, 0, sizeof(struct smc_local));
985 /* Fill in the fields of the device structure with ethernet values. */
986 ether_setup(dev);
988 /* Grab the IRQ */
989 retval = request_irq(dev->irq, &smc_interrupt, 0, dev->name, dev);
990 if (retval) {
991 printk("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
992 dev->irq, retval);
993 kfree(dev->priv);
994 dev->priv = NULL;
995 goto err_out;
998 dev->open = smc_open;
999 dev->stop = smc_close;
1000 dev->hard_start_xmit = smc_wait_to_send_packet;
1001 dev->tx_timeout = smc_timeout;
1002 dev->watchdog_timeo = HZ/20;
1003 dev->get_stats = smc_query_statistics;
1004 dev->set_multicast_list = smc_set_multicast_list;
1006 return 0;
1008 err_out:
1009 release_region(ioaddr, SMC_IO_EXTENT);
1010 return retval;
1013 #if SMC_DEBUG > 2
1014 static void print_packet( byte * buf, int length )
1016 #if 0
1017 int i;
1018 int remainder;
1019 int lines;
1021 printk("Packet of length %d \n", length );
1022 lines = length / 16;
1023 remainder = length % 16;
1025 for ( i = 0; i < lines ; i ++ ) {
1026 int cur;
1028 for ( cur = 0; cur < 8; cur ++ ) {
1029 byte a, b;
1031 a = *(buf ++ );
1032 b = *(buf ++ );
1033 printk("%02x%02x ", a, b );
1035 printk("\n");
1037 for ( i = 0; i < remainder/2 ; i++ ) {
1038 byte a, b;
1040 a = *(buf ++ );
1041 b = *(buf ++ );
1042 printk("%02x%02x ", a, b );
1044 printk("\n");
1045 #endif
1047 #endif
1051 * Open and Initialize the board
1053 * Set up everything, reset the card, etc ..
1056 static int smc_open(struct net_device *dev)
1058 int ioaddr = dev->base_addr;
1060 int i; /* used to set hw ethernet address */
1062 /* clear out all the junk that was put here before... */
1063 memset(dev->priv, 0, sizeof(struct smc_local));
1065 /* reset the hardware */
1067 smc_reset( ioaddr );
1068 smc_enable( ioaddr );
1070 /* Select which interface to use */
1072 SMC_SELECT_BANK( 1 );
1073 if ( dev->if_port == 1 ) {
1074 outw( inw( ioaddr + CONFIG ) & ~CFG_AUI_SELECT,
1075 ioaddr + CONFIG );
1077 else if ( dev->if_port == 2 ) {
1078 outw( inw( ioaddr + CONFIG ) | CFG_AUI_SELECT,
1079 ioaddr + CONFIG );
1083 According to Becker, I have to set the hardware address
1084 at this point, because the (l)user can set it with an
1085 ioctl. Easily done...
1087 SMC_SELECT_BANK( 1 );
1088 for ( i = 0; i < 6; i += 2 ) {
1089 word address;
1091 address = dev->dev_addr[ i + 1 ] << 8 ;
1092 address |= dev->dev_addr[ i ];
1093 outw( address, ioaddr + ADDR0 + i );
1096 netif_start_queue(dev);
1097 return 0;
1100 /*--------------------------------------------------------
1101 . Called by the kernel to send a packet out into the void
1102 . of the net. This routine is largely based on
1103 . skeleton.c, from Becker.
1104 .--------------------------------------------------------
1107 static void smc_timeout(struct net_device *dev)
1109 /* If we get here, some higher level has decided we are broken.
1110 There should really be a "kick me" function call instead. */
1111 printk(KERN_WARNING CARDNAME": transmit timed out, %s?\n",
1112 tx_done(dev) ? "IRQ conflict" :
1113 "network cable problem");
1114 /* "kick" the adaptor */
1115 smc_reset( dev->base_addr );
1116 smc_enable( dev->base_addr );
1117 dev->trans_start = jiffies;
1118 /* clear anything saved */
1119 ((struct smc_local *)dev->priv)->saved_skb = NULL;
1120 netif_wake_queue(dev);
1123 /*--------------------------------------------------------------------
1125 . This is the main routine of the driver, to handle the device when
1126 . it needs some attention.
1128 . So:
1129 . first, save state of the chipset
1130 . branch off into routines to handle each case, and acknowledge
1131 . each to the interrupt register
1132 . and finally restore state.
1134 ---------------------------------------------------------------------*/
1136 static void smc_interrupt(int irq, void * dev_id, struct pt_regs * regs)
1138 struct net_device *dev = dev_id;
1139 int ioaddr = dev->base_addr;
1140 struct smc_local *lp = (struct smc_local *)dev->priv;
1142 byte status;
1143 word card_stats;
1144 byte mask;
1145 int timeout;
1146 /* state registers */
1147 word saved_bank;
1148 word saved_pointer;
1152 PRINTK3((CARDNAME": SMC interrupt started \n"));
1154 saved_bank = inw( ioaddr + BANK_SELECT );
1156 SMC_SELECT_BANK(2);
1157 saved_pointer = inw( ioaddr + POINTER );
1159 mask = inb( ioaddr + INT_MASK );
1160 /* clear all interrupts */
1161 outb( 0, ioaddr + INT_MASK );
1164 /* set a timeout value, so I don't stay here forever */
1165 timeout = 4;
1167 PRINTK2((KERN_WARNING CARDNAME ": MASK IS %x \n", mask ));
1168 do {
1169 /* read the status flag, and mask it */
1170 status = inb( ioaddr + INTERRUPT ) & mask;
1171 if (!status )
1172 break;
1174 PRINTK3((KERN_WARNING CARDNAME
1175 ": Handling interrupt status %x \n", status ));
1177 if (status & IM_RCV_INT) {
1178 /* Got a packet(s). */
1179 PRINTK2((KERN_WARNING CARDNAME
1180 ": Receive Interrupt\n"));
1181 smc_rcv(dev);
1182 } else if (status & IM_TX_INT ) {
1183 PRINTK2((KERN_WARNING CARDNAME
1184 ": TX ERROR handled\n"));
1185 smc_tx(dev);
1186 outb(IM_TX_INT, ioaddr + INTERRUPT );
1187 } else if (status & IM_TX_EMPTY_INT ) {
1188 /* update stats */
1189 SMC_SELECT_BANK( 0 );
1190 card_stats = inw( ioaddr + COUNTER );
1191 /* single collisions */
1192 lp->stats.collisions += card_stats & 0xF;
1193 card_stats >>= 4;
1194 /* multiple collisions */
1195 lp->stats.collisions += card_stats & 0xF;
1197 /* these are for when linux supports these statistics */
1199 SMC_SELECT_BANK( 2 );
1200 PRINTK2((KERN_WARNING CARDNAME
1201 ": TX_BUFFER_EMPTY handled\n"));
1202 outb( IM_TX_EMPTY_INT, ioaddr + INTERRUPT );
1203 mask &= ~IM_TX_EMPTY_INT;
1204 lp->stats.tx_packets += lp->packets_waiting;
1205 lp->packets_waiting = 0;
1207 } else if (status & IM_ALLOC_INT ) {
1208 PRINTK2((KERN_DEBUG CARDNAME
1209 ": Allocation interrupt \n"));
1210 /* clear this interrupt so it doesn't happen again */
1211 mask &= ~IM_ALLOC_INT;
1213 smc_hardware_send_packet( dev );
1215 /* enable xmit interrupts based on this */
1216 mask |= ( IM_TX_EMPTY_INT | IM_TX_INT );
1218 /* and let the card send more packets to me */
1219 netif_wake_queue(dev);
1221 PRINTK2((CARDNAME": Handoff done successfully.\n"));
1222 } else if (status & IM_RX_OVRN_INT ) {
1223 lp->stats.rx_errors++;
1224 lp->stats.rx_fifo_errors++;
1225 outb( IM_RX_OVRN_INT, ioaddr + INTERRUPT );
1226 } else if (status & IM_EPH_INT ) {
1227 PRINTK((CARDNAME ": UNSUPPORTED: EPH INTERRUPT \n"));
1228 } else if (status & IM_ERCV_INT ) {
1229 PRINTK((CARDNAME ": UNSUPPORTED: ERCV INTERRUPT \n"));
1230 outb( IM_ERCV_INT, ioaddr + INTERRUPT );
1232 } while ( timeout -- );
1235 /* restore state register */
1236 SMC_SELECT_BANK( 2 );
1237 outb( mask, ioaddr + INT_MASK );
1239 PRINTK3(( KERN_WARNING CARDNAME ": MASK is now %x \n", mask ));
1240 outw( saved_pointer, ioaddr + POINTER );
1242 SMC_SELECT_BANK( saved_bank );
1244 PRINTK3((CARDNAME ": Interrupt done\n"));
1245 return;
1248 /*-------------------------------------------------------------
1250 . smc_rcv - receive a packet from the card
1252 . There is ( at least ) a packet waiting to be read from
1253 . chip-memory.
1255 . o Read the status
1256 . o If an error, record it
1257 . o otherwise, read in the packet
1258 --------------------------------------------------------------
1260 static void smc_rcv(struct net_device *dev)
1262 struct smc_local *lp = (struct smc_local *)dev->priv;
1263 int ioaddr = dev->base_addr;
1264 int packet_number;
1265 word status;
1266 word packet_length;
1268 /* assume bank 2 */
1270 packet_number = inw( ioaddr + FIFO_PORTS );
1272 if ( packet_number & FP_RXEMPTY ) {
1273 /* we got called , but nothing was on the FIFO */
1274 PRINTK((CARDNAME ": WARNING: smc_rcv with nothing on FIFO. \n"));
1275 /* don't need to restore anything */
1276 return;
1279 /* start reading from the start of the packet */
1280 outw( PTR_READ | PTR_RCV | PTR_AUTOINC, ioaddr + POINTER );
1282 /* First two words are status and packet_length */
1283 status = inw( ioaddr + DATA_1 );
1284 packet_length = inw( ioaddr + DATA_1 );
1286 packet_length &= 0x07ff; /* mask off top bits */
1288 PRINTK2(("RCV: STATUS %4x LENGTH %4x\n", status, packet_length ));
1290 . the packet length contains 3 extra words :
1291 . status, length, and an extra word with an odd byte .
1293 packet_length -= 6;
1295 if ( !(status & RS_ERRORS ) ){
1296 /* do stuff to make a new packet */
1297 struct sk_buff * skb;
1298 byte * data;
1300 /* read one extra byte */
1301 if ( status & RS_ODDFRAME )
1302 packet_length++;
1304 /* set multicast stats */
1305 if ( status & RS_MULTICAST )
1306 lp->stats.multicast++;
1308 skb = dev_alloc_skb( packet_length + 5);
1310 if ( skb == NULL ) {
1311 printk(KERN_NOTICE CARDNAME ": Low memory, packet dropped.\n");
1312 lp->stats.rx_dropped++;
1313 goto done;
1317 ! This should work without alignment, but it could be
1318 ! in the worse case
1321 skb_reserve( skb, 2 ); /* 16 bit alignment */
1323 skb->dev = dev;
1324 data = skb_put( skb, packet_length);
1326 #ifdef USE_32_BIT
1327 /* QUESTION: Like in the TX routine, do I want
1328 to send the DWORDs or the bytes first, or some
1329 mixture. A mixture might improve already slow PIO
1330 performance */
1331 PRINTK3((" Reading %d dwords (and %d bytes) \n",
1332 packet_length >> 2, packet_length & 3 ));
1333 insl(ioaddr + DATA_1 , data, packet_length >> 2 );
1334 /* read the left over bytes */
1335 insb( ioaddr + DATA_1, data + (packet_length & 0xFFFFFC),
1336 packet_length & 0x3 );
1337 #else
1338 PRINTK3((" Reading %d words and %d byte(s) \n",
1339 (packet_length >> 1 ), packet_length & 1 ));
1340 insw(ioaddr + DATA_1 , data, packet_length >> 1);
1341 if ( packet_length & 1 ) {
1342 data += packet_length & ~1;
1343 *(data++) = inb( ioaddr + DATA_1 );
1345 #endif
1346 #if SMC_DEBUG > 2
1347 print_packet( data, packet_length );
1348 #endif
1350 skb->protocol = eth_type_trans(skb, dev );
1351 netif_rx(skb);
1352 dev->last_rx = jiffies;
1353 lp->stats.rx_packets++;
1354 lp->stats.rx_bytes += packet_length;
1355 } else {
1356 /* error ... */
1357 lp->stats.rx_errors++;
1359 if ( status & RS_ALGNERR ) lp->stats.rx_frame_errors++;
1360 if ( status & (RS_TOOSHORT | RS_TOOLONG ) )
1361 lp->stats.rx_length_errors++;
1362 if ( status & RS_BADCRC) lp->stats.rx_crc_errors++;
1365 done:
1366 /* error or good, tell the card to get rid of this packet */
1367 outw( MC_RELEASE, ioaddr + MMU_CMD );
1371 /*************************************************************************
1372 . smc_tx
1374 . Purpose: Handle a transmit error message. This will only be called
1375 . when an error, because of the AUTO_RELEASE mode.
1377 . Algorithm:
1378 . Save pointer and packet no
1379 . Get the packet no from the top of the queue
1380 . check if it's valid ( if not, is this an error??? )
1381 . read the status word
1382 . record the error
1383 . ( resend? Not really, since we don't want old packets around )
1384 . Restore saved values
1385 ************************************************************************/
1386 static void smc_tx( struct net_device * dev )
1388 int ioaddr = dev->base_addr;
1389 struct smc_local *lp = (struct smc_local *)dev->priv;
1390 byte saved_packet;
1391 byte packet_no;
1392 word tx_status;
1395 /* assume bank 2 */
1397 saved_packet = inb( ioaddr + PNR_ARR );
1398 packet_no = inw( ioaddr + FIFO_PORTS );
1399 packet_no &= 0x7F;
1401 /* select this as the packet to read from */
1402 outb( packet_no, ioaddr + PNR_ARR );
1404 /* read the first word from this packet */
1405 outw( PTR_AUTOINC | PTR_READ, ioaddr + POINTER );
1407 tx_status = inw( ioaddr + DATA_1 );
1408 PRINTK3((CARDNAME": TX DONE STATUS: %4x \n", tx_status ));
1410 lp->stats.tx_errors++;
1411 if ( tx_status & TS_LOSTCAR ) lp->stats.tx_carrier_errors++;
1412 if ( tx_status & TS_LATCOL ) {
1413 printk(KERN_DEBUG CARDNAME
1414 ": Late collision occurred on last xmit.\n");
1415 lp->stats.tx_window_errors++;
1417 #if 0
1418 if ( tx_status & TS_16COL ) { ... }
1419 #endif
1421 if ( tx_status & TS_SUCCESS ) {
1422 printk(CARDNAME": Successful packet caused interrupt \n");
1424 /* re-enable transmit */
1425 SMC_SELECT_BANK( 0 );
1426 outw( inw( ioaddr + TCR ) | TCR_ENABLE, ioaddr + TCR );
1428 /* kill the packet */
1429 SMC_SELECT_BANK( 2 );
1430 outw( MC_FREEPKT, ioaddr + MMU_CMD );
1432 /* one less packet waiting for me */
1433 lp->packets_waiting--;
1435 outb( saved_packet, ioaddr + PNR_ARR );
1436 return;
1439 /*----------------------------------------------------
1440 . smc_close
1442 . this makes the board clean up everything that it can
1443 . and not talk to the outside world. Caused by
1444 . an 'ifconfig ethX down'
1446 -----------------------------------------------------*/
1447 static int smc_close(struct net_device *dev)
1449 netif_stop_queue(dev);
1450 /* clear everything */
1451 smc_shutdown( dev->base_addr );
1453 /* Update the statistics here. */
1454 return 0;
1457 /*------------------------------------------------------------
1458 . Get the current statistics.
1459 . This may be called with the card open or closed.
1460 .-------------------------------------------------------------*/
1461 static struct net_device_stats* smc_query_statistics(struct net_device *dev) {
1462 struct smc_local *lp = (struct smc_local *)dev->priv;
1464 return &lp->stats;
1467 /*-----------------------------------------------------------
1468 . smc_set_multicast_list
1470 . This routine will, depending on the values passed to it,
1471 . either make it accept multicast packets, go into
1472 . promiscuous mode ( for TCPDUMP and cousins ) or accept
1473 . a select set of multicast packets
1475 static void smc_set_multicast_list(struct net_device *dev)
1477 short ioaddr = dev->base_addr;
1479 SMC_SELECT_BANK(0);
1480 if ( dev->flags & IFF_PROMISC )
1481 outw( inw(ioaddr + RCR ) | RCR_PROMISC, ioaddr + RCR );
1483 /* BUG? I never disable promiscuous mode if multicasting was turned on.
1484 Now, I turn off promiscuous mode, but I don't do anything to multicasting
1485 when promiscuous mode is turned on.
1488 /* Here, I am setting this to accept all multicast packets.
1489 I don't need to zero the multicast table, because the flag is
1490 checked before the table is
1492 else if (dev->flags & IFF_ALLMULTI)
1493 outw( inw(ioaddr + RCR ) | RCR_ALMUL, ioaddr + RCR );
1495 /* We just get all multicast packets even if we only want them
1496 . from one source. This will be changed at some future
1497 . point. */
1498 else if (dev->mc_count ) {
1499 /* support hardware multicasting */
1501 /* be sure I get rid of flags I might have set */
1502 outw( inw( ioaddr + RCR ) & ~(RCR_PROMISC | RCR_ALMUL),
1503 ioaddr + RCR );
1504 /* NOTE: this has to set the bank, so make sure it is the
1505 last thing called. The bank is set to zero at the top */
1506 smc_setmulticast( ioaddr, dev->mc_count, dev->mc_list );
1508 else {
1509 outw( inw( ioaddr + RCR ) & ~(RCR_PROMISC | RCR_ALMUL),
1510 ioaddr + RCR );
1513 since I'm disabling all multicast entirely, I need to
1514 clear the multicast list
1516 SMC_SELECT_BANK( 3 );
1517 outw( 0, ioaddr + MULTICAST1 );
1518 outw( 0, ioaddr + MULTICAST2 );
1519 outw( 0, ioaddr + MULTICAST3 );
1520 outw( 0, ioaddr + MULTICAST4 );
1524 #ifdef MODULE
1526 static struct net_device devSMC9194;
1527 static int io;
1528 static int irq;
1529 static int ifport;
1530 MODULE_LICENSE("GPL");
1532 MODULE_PARM(io, "i");
1533 MODULE_PARM(irq, "i");
1534 MODULE_PARM(ifport, "i");
1535 MODULE_PARM_DESC(io, "SMC 99194 I/O base address");
1536 MODULE_PARM_DESC(irq, "SMC 99194 IRQ number");
1537 MODULE_PARM_DESC(ifport, "SMC 99194 interface port (0-default, 1-TP, 2-AUI)");
1539 int init_module(void)
1541 int result;
1543 if (io == 0)
1544 printk(KERN_WARNING
1545 CARDNAME": You shouldn't use auto-probing with insmod!\n" );
1547 /* copy the parameters from insmod into the device structure */
1548 devSMC9194.base_addr = io;
1549 devSMC9194.irq = irq;
1550 devSMC9194.if_port = ifport;
1551 devSMC9194.init = smc_init;
1552 if ((result = register_netdev(&devSMC9194)) != 0)
1553 return result;
1555 return 0;
1558 void cleanup_module(void)
1560 unregister_netdev(&devSMC9194);
1562 free_irq(devSMC9194.irq, &devSMC9194);
1563 release_region(devSMC9194.base_addr, SMC_IO_EXTENT);
1565 if (devSMC9194.priv)
1566 kfree(devSMC9194.priv);
1569 #endif /* MODULE */