Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / drivers / net / smc9194.c
blob41e5f53c9a359cc8b2c46ec2956d7da95f768c07
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 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@cesdis.gsfc.nasa.gov )
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 ----------------------------------------------------------------------------*/
56 static const char*version =
57 "smc9194.c:v0.14 12/15/00 by Erik Stahlman (erik@vt.edu)\n";
59 #include <linux/module.h>
60 #include <linux/version.h>
61 #include <linux/kernel.h>
62 #include <linux/sched.h>
63 #include <linux/types.h>
64 #include <linux/fcntl.h>
65 #include <linux/interrupt.h>
66 #include <linux/ptrace.h>
67 #include <linux/ioport.h>
68 #include <linux/in.h>
69 #include <linux/malloc.h>
70 #include <linux/string.h>
71 #include <linux/init.h>
72 #include <asm/bitops.h>
73 #include <asm/io.h>
74 #include <linux/errno.h>
76 #include <linux/netdevice.h>
77 #include <linux/etherdevice.h>
78 #include <linux/skbuff.h>
80 #include"smc9194.h"
81 /*------------------------------------------------------------------------
83 . Configuration options, for the experienced user to change.
85 -------------------------------------------------------------------------*/
88 . Do you want to use 32 bit xfers? This should work on all chips, as
89 . the chipset is designed to accommodate them.
91 #define USE_32_BIT 1
94 .the SMC9194 can be at any of the following port addresses. To change,
95 .for a slightly different card, you can add it to the array. Keep in
96 .mind that the array must end in zero.
98 static unsigned int smc_portlist[] __initdata = {
99 0x200,0x220,0x240,0x260,0x280,0x2A0,0x2C0,0x2E0,
100 0x300,0x320,0x340,0x360,0x380,0x3A0,0x3C0,0x3E0,0
104 . Wait time for memory to be free. This probably shouldn't be
105 . tuned that much, as waiting for this means nothing else happens
106 . in the system
108 #define MEMORY_WAIT_TIME 16
111 . DEBUGGING LEVELS
113 . 0 for normal operation
114 . 1 for slightly more details
115 . >2 for various levels of increasingly useless information
116 . 2 for interrupt tracking, status flags
117 . 3 for packet dumps, etc.
119 #define SMC_DEBUG 0
121 #if (SMC_DEBUG > 2 )
122 #define PRINTK3(x) printk x
123 #else
124 #define PRINTK3(x)
125 #endif
127 #if SMC_DEBUG > 1
128 #define PRINTK2(x) printk x
129 #else
130 #define PRINTK2(x)
131 #endif
133 #ifdef SMC_DEBUG
134 #define PRINTK(x) printk x
135 #else
136 #define PRINTK(x)
137 #endif
140 /*------------------------------------------------------------------------
142 . The internal workings of the driver. If you are changing anything
143 . here with the SMC stuff, you should have the datasheet and known
144 . what you are doing.
146 -------------------------------------------------------------------------*/
147 #define CARDNAME"SMC9194"
150 /* store this information for the driver.. */
151 struct smc_local {
153 these are things that the kernel wants me to keep, so users
154 can find out semi-useless statistics of how well the card is
155 performing
157 struct net_device_stats stats;
160 If I have to wait until memory is available to send
161 a packet, I will store the skbuff here, until I get the
162 desired memory. Then, I'll send it out and free it.
164 struct sk_buff * saved_skb;
167 . This keeps track of how many packets that I have
168 . sent out. When an TX_EMPTY interrupt comes, I know
169 . that all of these have been sent.
171 int packets_waiting;
175 /*-----------------------------------------------------------------
177 . The driver can be entered at any of the following entry points.
179 .------------------------------------------------------------------ */
182 . This is called by register_netdev(). It is responsible for
183 . checking the portlist for the SMC9000 series chipset. If it finds
184 . one, then it will initialize the device, find the hardware information,
185 . and sets up the appropriate device parameters.
186 . NOTE: Interrupts are *OFF* when this procedure is called.
188 . NB:This shouldn't be static since it is referred to externally.
190 intsmc_init(struct net_device *dev);
193 . The kernel calls this function when someone wants to use the device,
194 . typically 'ifconfig ethX up'.
196 static intsmc_open(struct net_device *dev);
199 . Our watchdog timed out. Called by the networking layer
201 static voidsmc_timeout(struct net_device *dev);
204 . This is called by the kernel in response to 'ifconfig ethX down'. It
205 . is responsible for cleaning up everything that the open routine
206 . does, and maybe putting the card into a powerdown state.
208 static intsmc_close(struct net_device *dev);
211 . This routine allows the proc file system to query the driver's
212 . statistics.
214 static struct net_device_stats *smc_query_statistics(struct net_device *dev);
217 . Finally, a call to set promiscuous mode ( for TCPDUMP and related
218 . programs ) and multicast modes.
220 static voidsmc_set_multicast_list(struct net_device *dev);
223 . CRC compute
225 static intcrc32(char* s,int length );
227 /*---------------------------------------------------------------
229 . Interrupt level calls..
231 ----------------------------------------------------------------*/
234 . Handles the actual interrupt
236 static voidsmc_interrupt(int irq,void*,struct pt_regs *regs);
238 . This is a separate procedure to handle the receipt of a packet, to
239 . leave the interrupt code looking slightly cleaner
241 inlinestatic voidsmc_rcv(struct net_device *dev );
243 . This handles a TX interrupt, which is only called when an error
244 . relating to a packet is sent.
246 inlinestatic voidsmc_tx(struct net_device * dev );
249 ------------------------------------------------------------
251 . Internal routines
253 ------------------------------------------------------------
257 . Test if a given location contains a chip, trying to cause as
258 . little damage as possible if it's not a SMC chip.
260 static intsmc_probe(struct net_device *dev,int ioaddr);
263 . A rather simple routine to print out a packet for debugging purposes.
265 #if SMC_DEBUG > 2
266 static voidprint_packet( byte *,int);
267 #endif
269 #define tx_done(dev) 1
271 /* this is called to actually send the packet to the chip */
272 static voidsmc_hardware_send_packet(struct net_device * dev );
274 /* Since I am not sure if I will have enough room in the chip's ram
275 . to store the packet, I call this routine, which either sends it
276 . now, or generates an interrupt when the card is ready for the
277 . packet */
278 static intsmc_wait_to_send_packet(struct sk_buff * skb,struct net_device *dev );
280 /* this does a soft reset on the device */
281 static voidsmc_reset(int ioaddr );
283 /* Enable Interrupts, Receive, and Transmit */
284 static voidsmc_enable(int ioaddr );
286 /* this puts the device in an inactive state */
287 static voidsmc_shutdown(int ioaddr );
289 /* This routine will find the IRQ of the driver if one is not
290 . specified in the input to the device. */
291 static intsmc_findirq(int ioaddr );
294 . Function: smc_reset( int ioaddr )
295 . Purpose:
296 . This sets the SMC91xx chip to its normal state, hopefully from whatever
297 . mess that any other DOS driver has put it in.
299 . Maybe I should reset more registers to defaults in here? SOFTRESET should
300 . do that for me.
302 . Method:
303 . 1. send a SOFT RESET
304 . 2. wait for it to finish
305 . 3. enable autorelease mode
306 . 4. reset the memory management unit
307 . 5. clear all interrupts
310 static voidsmc_reset(int ioaddr )
312 /* This resets the registers mostly to defaults, but doesn't
313 affect EEPROM. That seems unnecessary */
314 SMC_SELECT_BANK(0);
315 outw( RCR_SOFTRESET, ioaddr + RCR );
317 /* this should pause enough for the chip to be happy */
318 SMC_DELAY( );
320 /* Set the transmit and receive configuration registers to
321 default values */
322 outw( RCR_CLEAR, ioaddr + RCR );
323 outw( TCR_CLEAR, ioaddr + TCR );
325 /* set the control register to automatically
326 release successfully transmitted packets, to make the best
327 use out of our limited memory */
328 SMC_SELECT_BANK(1);
329 outw(inw( ioaddr + CONTROL ) | CTL_AUTO_RELEASE , ioaddr + CONTROL );
331 /* Reset the MMU */
332 SMC_SELECT_BANK(2);
333 outw( MC_RESET, ioaddr + MMU_CMD );
335 /* Note: It doesn't seem that waiting for the MMU busy is needed here,
336 but this is a place where future chipsets _COULD_ break. Be wary
337 of issuing another MMU command right after this */
339 outb(0, ioaddr + INT_MASK );
343 . Function: smc_enable
344 . Purpose: let the chip talk to the outside work
345 . Method:
346 . 1. Enable the transmitter
347 . 2. Enable the receiver
348 . 3. Enable interrupts
350 static voidsmc_enable(int ioaddr )
352 SMC_SELECT_BANK(0);
353 /* see the header file for options in TCR/RCR NORMAL*/
354 outw( TCR_NORMAL, ioaddr + TCR );
355 outw( RCR_NORMAL, ioaddr + RCR );
357 /* now, enable interrupts */
358 SMC_SELECT_BANK(2);
359 outb( SMC_INTERRUPT_MASK, ioaddr + INT_MASK );
363 . Function: smc_shutdown
364 . Purpose: closes down the SMC91xxx chip.
365 . Method:
366 . 1. zero the interrupt mask
367 . 2. clear the enable receive flag
368 . 3. clear the enable xmit flags
370 . TODO:
371 . (1) maybe utilize power down mode.
372 . Why not yet? Because while the chip will go into power down mode,
373 . the manual says that it will wake up in response to any I/O requests
374 . in the register space. Empirical results do not show this working.
376 static voidsmc_shutdown(int ioaddr )
378 /* no more interrupts for me */
379 SMC_SELECT_BANK(2);
380 outb(0, ioaddr + INT_MASK );
382 /* and tell the card to stay away from that nasty outside world */
383 SMC_SELECT_BANK(0);
384 outb( RCR_CLEAR, ioaddr + RCR );
385 outb( TCR_CLEAR, ioaddr + TCR );
386 #if 0
387 /* finally, shut the chip down */
388 SMC_SELECT_BANK(1);
389 outw(inw( ioaddr + CONTROL ), CTL_POWERDOWN, ioaddr + CONTROL );
390 #endif
395 . Function: smc_setmulticast( int ioaddr, int count, dev_mc_list * adds )
396 . Purpose:
397 . This sets the internal hardware table to filter out unwanted multicast
398 . packets before they take up memory.
400 . The SMC chip uses a hash table where the high 6 bits of the CRC of
401 . address are the offset into the table. If that bit is 1, then the
402 . multicast packet is accepted. Otherwise, it's dropped silently.
404 . To use the 6 bits as an offset into the table, the high 3 bits are the
405 . number of the 8 bit register, while the low 3 bits are the bit within
406 . that register.
408 . This routine is based very heavily on the one provided by Peter Cammaert.
412 static voidsmc_setmulticast(int ioaddr,int count,struct dev_mc_list * addrs ) {
413 int i;
414 unsigned char multicast_table[8];
415 struct dev_mc_list * cur_addr;
416 /* table for flipping the order of 3 bits */
417 unsigned char invert3[] = {0,4,2,6,1,5,3,7};
419 /* start with a table of all zeros: reject all */
420 memset( multicast_table,0,sizeof( multicast_table ) );
422 cur_addr = addrs;
423 for( i =0; i < count ; i ++, cur_addr = cur_addr->next ) {
424 int position;
426 /* do we have a pointer here? */
427 if( !cur_addr )
428 break;
429 /* make sure this is a multicast address - shouldn't this
430 be a given if we have it here ? */
431 if( !( *cur_addr->dmi_addr &1) )
432 continue;
434 /* only use the low order bits */
435 position =crc32( cur_addr->dmi_addr,6) &0x3f;
437 /* do some messy swapping to put the bit in the right spot */
438 multicast_table[invert3[position&7]] |=
439 (1<<invert3[(position>>3)&7]);
442 /* now, the table can be loaded into the chipset */
443 SMC_SELECT_BANK(3);
445 for( i =0; i <8; i++ ) {
446 outb( multicast_table[i], ioaddr + MULTICAST1 + i );
451 Finds the CRC32 of a set of bytes.
452 Again, from Peter Cammaert's code.
454 static intcrc32(char* s,int length ) {
455 /* indices */
456 int perByte;
457 int perBit;
458 /* crc polynomial for Ethernet */
459 const unsigned long poly =0xedb88320;
460 /* crc value - preinitialized to all 1's */
461 unsigned long crc_value =0xffffffff;
463 for( perByte =0; perByte < length; perByte ++ ) {
464 unsigned char c;
466 c = *(s++);
467 for( perBit =0; perBit <8; perBit++ ) {
468 crc_value = (crc_value>>1)^
469 (((crc_value^c)&0x01)?poly:0);
470 c >>=1;
473 return crc_value;
478 . Function: smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * )
479 . Purpose:
480 . Attempt to allocate memory for a packet, if chip-memory is not
481 . available, then tell the card to generate an interrupt when it
482 . is available.
484 . Algorithm:
486 . o if the saved_skb is not currently null, then drop this packet
487 . on the floor. This should never happen, because of TBUSY.
488 . o if the saved_skb is null, then replace it with the current packet,
489 . o See if I can sending it now.
490 . o (NO): Enable interrupts and let the interrupt handler deal with it.
491 . o (YES):Send it now.
493 static intsmc_wait_to_send_packet(struct sk_buff * skb,struct net_device * dev )
495 struct smc_local *lp = (struct smc_local *)dev->priv;
496 unsigned short ioaddr = dev->base_addr;
497 word length;
498 unsigned short numPages;
499 word time_out;
501 netif_stop_queue(dev);
502 /* Well, I want to send the packet.. but I don't know
503 if I can send it right now... */
505 if( lp->saved_skb) {
506 /* THIS SHOULD NEVER HAPPEN. */
507 lp->stats.tx_aborted_errors++;
508 printk(CARDNAME": Bad Craziness - sent packet while busy.\n");
509 return1;
511 lp->saved_skb = skb;
513 length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
517 ** The MMU wants the number of pages to be the number of 256 bytes
518 ** 'pages', minus 1 ( since a packet can't ever have 0 pages :) )
520 ** Pkt size for allocating is data length +6 (for additional status words,
521 ** length and ctl!) If odd size last byte is included in this header.
523 numPages = ((length &0xfffe) +6) /256;
525 if(numPages >7) {
526 printk(CARDNAME": Far too big packet error.\n");
527 /* freeing the packet is a good thing here... but should
528 . any packets of this size get down here? */
529 dev_kfree_skb(skb);
530 lp->saved_skb = NULL;
531 /* this IS an error, but, i don't want the skb saved */
532 netif_wake_queue(dev);
533 return0;
535 /* either way, a packet is waiting now */
536 lp->packets_waiting++;
538 /* now, try to allocate the memory */
539 SMC_SELECT_BANK(2);
540 outw( MC_ALLOC | numPages, ioaddr + MMU_CMD );
542 . Performance Hack
544 . wait a short amount of time.. if I can send a packet now, I send
545 . it now. Otherwise, I enable an interrupt and wait for one to be
546 . available.
548 . I could have handled this a slightly different way, by checking to
549 . see if any memory was available in the FREE MEMORY register. However,
550 . either way, I need to generate an allocation, and the allocation works
551 . no matter what, so I saw no point in checking free memory.
553 time_out = MEMORY_WAIT_TIME;
555 word status;
557 status =inb( ioaddr + INTERRUPT );
558 if( status & IM_ALLOC_INT ) {
559 /* acknowledge the interrupt */
560 outb( IM_ALLOC_INT, ioaddr + INTERRUPT );
561 break;
563 }while( -- time_out );
565 if( !time_out ) {
566 /* oh well, wait until the chip finds memory later */
567 SMC_ENABLE_INT( IM_ALLOC_INT );
568 PRINTK2((CARDNAME": memory allocation deferred.\n"));
569 /* it's deferred, but I'll handle it later */
570 return0;
572 /* or YES! I can send the packet now.. */
573 smc_hardware_send_packet(dev);
574 netif_wake_queue(dev);
575 return0;
579 . Function: smc_hardware_send_packet(struct net_device * )
580 . Purpose:
581 . This sends the actual packet to the SMC9xxx chip.
583 . Algorithm:
584 . First, see if a saved_skb is available.
585 . ( this should NOT be called if there is no 'saved_skb'
586 . Now, find the packet number that the chip allocated
587 . Point the data pointers at it in memory
588 . Set the length word in the chip's memory
589 . Dump the packet to chip memory
590 . Check if a last byte is needed ( odd length packet )
591 . if so, set the control flag right
592 . Tell the card to send it
593 . Enable the transmit interrupt, so I know if it failed
594 . Free the kernel data if I actually sent it.
596 static voidsmc_hardware_send_packet(struct net_device * dev )
598 struct smc_local *lp = (struct smc_local *)dev->priv;
599 byte packet_no;
600 struct sk_buff * skb = lp->saved_skb;
601 word length;
602 unsigned short ioaddr;
603 byte * buf;
605 ioaddr = dev->base_addr;
607 if( !skb ) {
608 PRINTK((CARDNAME": In XMIT with no packet to send\n"));
609 return;
611 length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
612 buf = skb->data;
614 /* If I get here, I _know_ there is a packet slot waiting for me */
615 packet_no =inb( ioaddr + PNR_ARR +1);
616 if( packet_no &0x80) {
617 /* or isn't there? BAD CHIP! */
618 printk(KERN_DEBUG CARDNAME": Memory allocation failed.\n");
619 dev_kfree_skb_irq(skb);
620 lp->saved_skb = NULL;
621 netif_wake_queue(dev);
622 return;
625 /* we have a packet address, so tell the card to use it */
626 outb( packet_no, ioaddr + PNR_ARR );
628 /* point to the beginning of the packet */
629 outw( PTR_AUTOINC , ioaddr + POINTER );
631 PRINTK3((CARDNAME": Trying to xmit packet of length %x\n", length ));
632 #if SMC_DEBUG > 2
633 print_packet( buf, length );
634 #endif
636 /* send the packet length ( +6 for status, length and ctl byte )
637 and the status word ( set to zeros ) */
638 #ifdef USE_32_BIT
639 outl( (length +6) <<16, ioaddr + DATA_1 );
640 #else
641 outw(0, ioaddr + DATA_1 );
642 /* send the packet length ( +6 for status words, length, and ctl*/
643 outb( (length+6) &0xFF,ioaddr + DATA_1 );
644 outb( (length+6) >>8, ioaddr + DATA_1 );
645 #endif
647 /* send the actual data
648 . I _think_ it's faster to send the longs first, and then
649 . mop up by sending the last word. It depends heavily
650 . on alignment, at least on the 486. Maybe it would be
651 . a good idea to check which is optimal? But that could take
652 . almost as much time as is saved?
654 #ifdef USE_32_BIT
655 if( length &0x2) {
656 outsl(ioaddr + DATA_1, buf, length >>2);
657 outw( *((word *)(buf + (length &0xFFFFFFFC))),ioaddr +DATA_1);
659 else
660 outsl(ioaddr + DATA_1, buf, length >>2);
661 #else
662 outsw(ioaddr + DATA_1 , buf, (length ) >>1);
663 #endif
664 /* Send the last byte, if there is one. */
666 if( (length &1) ==0) {
667 outw(0, ioaddr + DATA_1 );
668 }else{
669 outb( buf[length -1], ioaddr + DATA_1 );
670 outb(0x20, ioaddr + DATA_1);
673 /* enable the interrupts */
674 SMC_ENABLE_INT( (IM_TX_INT | IM_TX_EMPTY_INT) );
676 /* and let the chipset deal with it */
677 outw( MC_ENQUEUE , ioaddr + MMU_CMD );
679 PRINTK2((CARDNAME": Sent packet of length %d\n",length));
681 lp->saved_skb = NULL;
682 dev_kfree_skb_irq(skb);
684 dev->trans_start = jiffies;
686 /* we can send another packet */
687 netif_wake_queue(dev);
689 return;
692 /*-------------------------------------------------------------------------
694 | smc_init( struct net_device * dev )
695 | Input parameters:
696 | dev->base_addr == 0, try to find all possible locations
697 | dev->base_addr == 1, return failure code
698 | dev->base_addr == 2, always allocate space, and return success
699 | dev->base_addr == <anything else> this is the address to check
701 | Output:
702 | 0 --> there is a device
703 | anything else, error
705 ---------------------------------------------------------------------------
707 int __init smc_init(struct net_device *dev)
709 int i;
710 int base_addr = dev->base_addr;
712 SET_MODULE_OWNER(dev);
714 /* try a specific location */
715 if(base_addr >0x1ff)
716 returnsmc_probe(dev, base_addr);
717 else if(base_addr !=0)
718 return-ENXIO;
720 /* check every ethernet address */
721 for(i =0; smc_portlist[i]; i++)
722 if(smc_probe(dev, smc_portlist[i]) ==0)
723 return0;
725 /* couldn't find anything */
726 return-ENODEV;
729 /*----------------------------------------------------------------------
730 . smc_findirq
732 . This routine has a simple purpose -- make the SMC chip generate an
733 . interrupt, so an auto-detect routine can detect it, and find the IRQ,
734 ------------------------------------------------------------------------
736 int __init smc_findirq(int ioaddr )
738 int timeout =20;
739 unsigned long cookie;
742 /* I have to do a STI() here, because this is called from
743 a routine that does an CLI during this process, making it
744 rather difficult to get interrupts for auto detection */
745 sti();
747 cookie =probe_irq_on();
750 * What I try to do here is trigger an ALLOC_INT. This is done
751 * by allocating a small chunk of memory, which will give an interrupt
752 * when done.
756 SMC_SELECT_BANK(2);
757 /* enable ALLOCation interrupts ONLY */
758 outb( IM_ALLOC_INT, ioaddr + INT_MASK );
761 . Allocate 512 bytes of memory. Note that the chip was just
762 . reset so all the memory is available
764 outw( MC_ALLOC |1, ioaddr + MMU_CMD );
767 . Wait until positive that the interrupt has been generated
769 while( timeout ) {
770 byte int_status;
772 int_status =inb( ioaddr + INTERRUPT );
774 if( int_status & IM_ALLOC_INT )
775 break;/* got the interrupt */
776 timeout--;
778 /* there is really nothing that I can do here if timeout fails,
779 as autoirq_report will return a 0 anyway, which is what I
780 want in this case. Plus, the clean up is needed in both
781 cases. */
783 /* DELAY HERE!
784 On a fast machine, the status might change before the interrupt
785 is given to the processor. This means that the interrupt was
786 never detected, and autoirq_report fails to report anything.
787 This should fix autoirq_* problems.
789 SMC_DELAY();
790 SMC_DELAY();
792 /* and disable all interrupts again */
793 outb(0, ioaddr + INT_MASK );
795 /* clear hardware interrupts again, because that's how it
796 was when I was called... */
797 cli();
799 /* and return what I found */
800 returnprobe_irq_off(cookie);
803 /*----------------------------------------------------------------------
804 . Function: smc_probe( int ioaddr )
806 . Purpose:
807 . Tests to see if a given ioaddr points to an SMC9xxx chip.
808 . Returns a 0 on success
810 . Algorithm:
811 . (1) see if the high byte of BANK_SELECT is 0x33
812 . (2) compare the ioaddr with the base register's address
813 . (3) see if I recognize the chip ID in the appropriate register
815 .---------------------------------------------------------------------
818 /*---------------------------------------------------------------
819 . Here I do typical initialization tasks.
821 . o Initialize the structure if needed
822 . o print out my vanity message if not done so already
823 . o print out what type of hardware is detected
824 . o print out the ethernet address
825 . o find the IRQ
826 . o set up my private data
827 . o configure the dev structure with my subroutines
828 . o actually GRAB the irq.
829 . o GRAB the region
830 .-----------------------------------------------------------------
832 static int __init smc_probe(struct net_device *dev,int ioaddr)
834 int i, memory, retval;
835 static unsigned version_printed;
836 unsigned int bank;
838 const char*version_string;
839 const char*if_string;
841 /* registers */
842 word revision_register;
843 word base_address_register;
844 word configuration_register;
845 word memory_info_register;
846 word memory_cfg_register;
848 /* Grab the region so that no one else tries to probe our ioports. */
849 if(!request_region(ioaddr, SMC_IO_EXTENT, dev->name))
850 return-EBUSY;
852 /* First, see if the high byte is 0x33 */
853 bank =inw( ioaddr + BANK_SELECT );
854 if( (bank &0xFF00) !=0x3300) {
855 retval = -ENODEV;
856 goto err_out;
858 /* The above MIGHT indicate a device, but I need to write to further
859 test this. */
860 outw(0x0, ioaddr + BANK_SELECT );
861 bank =inw( ioaddr + BANK_SELECT );
862 if( (bank &0xFF00) !=0x3300) {
863 retval = -ENODEV;
864 goto err_out;
866 /* well, we've already written once, so hopefully another time won't
867 hurt. This time, I need to switch the bank register to bank 1,
868 so I can access the base address register */
869 SMC_SELECT_BANK(1);
870 base_address_register =inw( ioaddr + BASE );
871 if( ioaddr != ( base_address_register >>3&0x3E0) ) {
872 printk(CARDNAME ": IOADDR %x doesn't match configuration (%x)."
873 "Probably not a SMC chip\n",
874 ioaddr, base_address_register >>3&0x3E0);
875 /* well, the base address register didn't match. Must not have
876 been a SMC chip after all. */
877 retval = -ENODEV;
878 goto err_out;
881 /* check if the revision register is something that I recognize.
882 These might need to be added to later, as future revisions
883 could be added. */
884 SMC_SELECT_BANK(3);
885 revision_register =inw( ioaddr + REVISION );
886 if( !chip_ids[ ( revision_register >>4) &0xF] ) {
887 /* I don't recognize this chip, so... */
888 printk(CARDNAME ": IO %x: Unrecognized revision register:"
889 " %x, Contact author.\n", ioaddr, revision_register );
891 retval = -ENODEV;
892 goto err_out;
895 /* at this point I'll assume that the chip is an SMC9xxx.
896 It might be prudent to check a listing of MAC addresses
897 against the hardware address, or do some other tests. */
899 if(version_printed++ ==0)
900 printk("%s", version);
902 /* fill in some of the fields */
903 dev->base_addr = ioaddr;
906 . Get the MAC address ( bank 1, regs 4 - 9 )
908 SMC_SELECT_BANK(1);
909 for( i =0; i <6; i +=2) {
910 word address;
912 address =inw( ioaddr + ADDR0 + i );
913 dev->dev_addr[ i +1] = address >>8;
914 dev->dev_addr[ i ] = address &0xFF;
917 /* get the memory information */
919 SMC_SELECT_BANK(0);
920 memory_info_register =inw( ioaddr + MIR );
921 memory_cfg_register =inw( ioaddr + MCR );
922 memory = ( memory_cfg_register >>9) &0x7;/* multiplier */
923 memory *=256* ( memory_info_register &0xFF);
926 Now, I want to find out more about the chip. This is sort of
927 redundant, but it's cleaner to have it in both, rather than having
928 one VERY long probe procedure.
930 SMC_SELECT_BANK(3);
931 revision_register =inw( ioaddr + REVISION );
932 version_string = chip_ids[ ( revision_register >>4) &0xF];
933 if( !version_string ) {
934 /* I shouldn't get here because this call was done before.... */
935 retval = -ENODEV;
936 goto err_out;
939 /* is it using AUI or 10BaseT ? */
940 if( dev->if_port ==0) {
941 SMC_SELECT_BANK(1);
942 configuration_register =inw( ioaddr + CONFIG );
943 if( configuration_register & CFG_AUI_SELECT )
944 dev->if_port =2;
945 else
946 dev->if_port =1;
948 if_string = interfaces[ dev->if_port -1];
950 /* now, reset the chip, and put it into a known state */
951 smc_reset( ioaddr );
954 . If dev->irq is 0, then the device has to be banged on to see
955 . what the IRQ is.
957 . This banging doesn't always detect the IRQ, for unknown reasons.
958 . a workaround is to reset the chip and try again.
960 . Interestingly, the DOS packet driver *SETS* the IRQ on the card to
961 . be what is requested on the command line. I don't do that, mostly
962 . because the card that I have uses a non-standard method of accessing
963 . the IRQs, and because this _should_ work in most configurations.
965 . Specifying an IRQ is done with the assumption that the user knows
966 . what (s)he is doing. No checking is done!!!!
969 if( dev->irq <2) {
970 int trials;
972 trials =3;
973 while( trials-- ) {
974 dev->irq =smc_findirq( ioaddr );
975 if( dev->irq )
976 break;
977 /* kick the card and try again */
978 smc_reset( ioaddr );
981 if(dev->irq ==0) {
982 printk(CARDNAME": Couldn't autodetect your IRQ. Use irq=xx.\n");
983 retval = -ENODEV;
984 goto err_out;
986 if(dev->irq ==2) {
987 /* Fixup for users that don't know that IRQ 2 is really IRQ 9,
988 * or don't know which one to set.
990 dev->irq =9;
993 /* now, print out the card info, in a short format.. */
995 printk("%s: %s(r:%d) at %#3x IRQ:%d INTF:%s MEM:%db ", dev->name,
996 version_string, revision_register &0xF, ioaddr, dev->irq,
997 if_string, memory );
999 . Print the Ethernet address
1001 printk("ADDR: ");
1002 for(i =0; i <5; i++)
1003 printk("%2.2x:", dev->dev_addr[i] );
1004 printk("%2.2x\n", dev->dev_addr[5] );
1007 /* Initialize the private structure. */
1008 if(dev->priv == NULL) {
1009 dev->priv =kmalloc(sizeof(struct smc_local), GFP_KERNEL);
1010 if(dev->priv == NULL) {
1011 retval = -ENOMEM;
1012 goto err_out;
1015 /* set the private data to zero by default */
1016 memset(dev->priv,0,sizeof(struct smc_local));
1018 /* Fill in the fields of the device structure with ethernet values. */
1019 ether_setup(dev);
1021 /* Grab the IRQ */
1022 retval =request_irq(dev->irq, &smc_interrupt,0, dev->name, dev);
1023 if(retval) {
1024 printk("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
1025 dev->irq, retval);
1026 kfree(dev->priv);
1027 dev->priv = NULL;
1028 goto err_out;
1031 dev->open = smc_open;
1032 dev->stop = smc_close;
1033 dev->hard_start_xmit = smc_wait_to_send_packet;
1034 dev->tx_timeout = smc_timeout;
1035 dev->watchdog_timeo = HZ/20;
1036 dev->get_stats = smc_query_statistics;
1037 dev->set_multicast_list = smc_set_multicast_list;
1039 return0;
1041 err_out:
1042 release_region(ioaddr, SMC_IO_EXTENT);
1043 return retval;
1046 #if SMC_DEBUG > 2
1047 static voidprint_packet( byte * buf,int length )
1049 #if 0
1050 int i;
1051 int remainder;
1052 int lines;
1054 printk("Packet of length %d\n", length );
1055 lines = length /16;
1056 remainder = length %16;
1058 for( i =0; i < lines ; i ++ ) {
1059 int cur;
1061 for( cur =0; cur <8; cur ++ ) {
1062 byte a, b;
1064 a = *(buf ++ );
1065 b = *(buf ++ );
1066 printk("%02x%02x ", a, b );
1068 printk("\n");
1070 for( i =0; i < remainder/2; i++ ) {
1071 byte a, b;
1073 a = *(buf ++ );
1074 b = *(buf ++ );
1075 printk("%02x%02x ", a, b );
1077 printk("\n");
1078 #endif
1080 #endif
1084 * Open and Initialize the board
1086 * Set up everything, reset the card, etc ..
1089 static intsmc_open(struct net_device *dev)
1091 int ioaddr = dev->base_addr;
1093 int i;/* used to set hw ethernet address */
1095 /* clear out all the junk that was put here before... */
1096 memset(dev->priv,0,sizeof(struct smc_local));
1098 /* reset the hardware */
1100 smc_reset( ioaddr );
1101 smc_enable( ioaddr );
1103 /* Select which interface to use */
1105 SMC_SELECT_BANK(1);
1106 if( dev->if_port ==1) {
1107 outw(inw( ioaddr + CONFIG ) & ~CFG_AUI_SELECT,
1108 ioaddr + CONFIG );
1110 else if( dev->if_port ==2) {
1111 outw(inw( ioaddr + CONFIG ) | CFG_AUI_SELECT,
1112 ioaddr + CONFIG );
1116 According to Becker, I have to set the hardware address
1117 at this point, because the (l)user can set it with an
1118 ioctl. Easily done...
1120 SMC_SELECT_BANK(1);
1121 for( i =0; i <6; i +=2) {
1122 word address;
1124 address = dev->dev_addr[ i +1] <<8;
1125 address |= dev->dev_addr[ i ];
1126 outw( address, ioaddr + ADDR0 + i );
1129 netif_start_queue(dev);
1130 return0;
1133 /*--------------------------------------------------------
1134 . Called by the kernel to send a packet out into the void
1135 . of the net. This routine is largely based on
1136 . skeleton.c, from Becker.
1137 .--------------------------------------------------------
1140 static voidsmc_timeout(struct net_device *dev)
1142 /* If we get here, some higher level has decided we are broken.
1143 There should really be a "kick me" function call instead. */
1144 printk(KERN_WARNING CARDNAME": transmit timed out, %s?\n",
1145 tx_done(dev) ?"IRQ conflict":
1146 "network cable problem");
1147 /* "kick" the adaptor */
1148 smc_reset( dev->base_addr );
1149 smc_enable( dev->base_addr );
1150 dev->trans_start = jiffies;
1151 /* clear anything saved */
1152 ((struct smc_local *)dev->priv)->saved_skb = NULL;
1153 netif_wake_queue(dev);
1156 /*--------------------------------------------------------------------
1158 . This is the main routine of the driver, to handle the device when
1159 . it needs some attention.
1161 . So:
1162 . first, save state of the chipset
1163 . branch off into routines to handle each case, and acknowledge
1164 . each to the interrupt register
1165 . and finally restore state.
1167 ---------------------------------------------------------------------*/
1169 static voidsmc_interrupt(int irq,void* dev_id,struct pt_regs * regs)
1171 struct net_device *dev = dev_id;
1172 int ioaddr = dev->base_addr;
1173 struct smc_local *lp = (struct smc_local *)dev->priv;
1175 byte status;
1176 word card_stats;
1177 byte mask;
1178 int timeout;
1179 /* state registers */
1180 word saved_bank;
1181 word saved_pointer;
1185 PRINTK3((CARDNAME": SMC interrupt started\n"));
1187 saved_bank =inw( ioaddr + BANK_SELECT );
1189 SMC_SELECT_BANK(2);
1190 saved_pointer =inw( ioaddr + POINTER );
1192 mask =inb( ioaddr + INT_MASK );
1193 /* clear all interrupts */
1194 outb(0, ioaddr + INT_MASK );
1197 /* set a timeout value, so I don't stay here forever */
1198 timeout =4;
1200 PRINTK2((KERN_WARNING CARDNAME ": MASK IS %x\n", mask ));
1202 /* read the status flag, and mask it */
1203 status =inb( ioaddr + INTERRUPT ) & mask;
1204 if(!status )
1205 break;
1207 PRINTK3((KERN_WARNING CARDNAME
1208 ": Handling interrupt status %x\n", status ));
1210 if(status & IM_RCV_INT) {
1211 /* Got a packet(s). */
1212 PRINTK2((KERN_WARNING CARDNAME
1213 ": Receive Interrupt\n"));
1214 smc_rcv(dev);
1215 }else if(status & IM_TX_INT ) {
1216 PRINTK2((KERN_WARNING CARDNAME
1217 ": TX ERROR handled\n"));
1218 smc_tx(dev);
1219 outb(IM_TX_INT, ioaddr + INTERRUPT );
1220 }else if(status & IM_TX_EMPTY_INT ) {
1221 /* update stats */
1222 SMC_SELECT_BANK(0);
1223 card_stats =inw( ioaddr + COUNTER );
1224 /* single collisions */
1225 lp->stats.collisions += card_stats &0xF;
1226 card_stats >>=4;
1227 /* multiple collisions */
1228 lp->stats.collisions += card_stats &0xF;
1230 /* these are for when linux supports these statistics */
1232 SMC_SELECT_BANK(2);
1233 PRINTK2((KERN_WARNING CARDNAME
1234 ": TX_BUFFER_EMPTY handled\n"));
1235 outb( IM_TX_EMPTY_INT, ioaddr + INTERRUPT );
1236 mask &= ~IM_TX_EMPTY_INT;
1237 lp->stats.tx_packets += lp->packets_waiting;
1238 lp->packets_waiting =0;
1240 }else if(status & IM_ALLOC_INT ) {
1241 PRINTK2((KERN_DEBUG CARDNAME
1242 ": Allocation interrupt\n"));
1243 /* clear this interrupt so it doesn't happen again */
1244 mask &= ~IM_ALLOC_INT;
1246 smc_hardware_send_packet( dev );
1248 /* enable xmit interrupts based on this */
1249 mask |= ( IM_TX_EMPTY_INT | IM_TX_INT );
1251 /* and let the card send more packets to me */
1252 netif_wake_queue(dev);
1254 PRINTK2((CARDNAME": Handoff done successfully.\n"));
1255 }else if(status & IM_RX_OVRN_INT ) {
1256 lp->stats.rx_errors++;
1257 lp->stats.rx_fifo_errors++;
1258 outb( IM_RX_OVRN_INT, ioaddr + INTERRUPT );
1259 }else if(status & IM_EPH_INT ) {
1260 PRINTK((CARDNAME ": UNSUPPORTED: EPH INTERRUPT\n"));
1261 }else if(status & IM_ERCV_INT ) {
1262 PRINTK((CARDNAME ": UNSUPPORTED: ERCV INTERRUPT\n"));
1263 outb( IM_ERCV_INT, ioaddr + INTERRUPT );
1265 }while( timeout -- );
1268 /* restore state register */
1269 SMC_SELECT_BANK(2);
1270 outb( mask, ioaddr + INT_MASK );
1272 PRINTK3(( KERN_WARNING CARDNAME ": MASK is now %x\n", mask ));
1273 outw( saved_pointer, ioaddr + POINTER );
1275 SMC_SELECT_BANK( saved_bank );
1277 PRINTK3((CARDNAME ": Interrupt done\n"));
1278 return;
1281 /*-------------------------------------------------------------
1283 . smc_rcv - receive a packet from the card
1285 . There is ( at least ) a packet waiting to be read from
1286 . chip-memory.
1288 . o Read the status
1289 . o If an error, record it
1290 . o otherwise, read in the packet
1291 --------------------------------------------------------------
1293 static voidsmc_rcv(struct net_device *dev)
1295 struct smc_local *lp = (struct smc_local *)dev->priv;
1296 int ioaddr = dev->base_addr;
1297 int packet_number;
1298 word status;
1299 word packet_length;
1301 /* assume bank 2 */
1303 packet_number =inw( ioaddr + FIFO_PORTS );
1305 if( packet_number & FP_RXEMPTY ) {
1306 /* we got called , but nothing was on the FIFO */
1307 PRINTK((CARDNAME ": WARNING: smc_rcv with nothing on FIFO.\n"));
1308 /* don't need to restore anything */
1309 return;
1312 /* start reading from the start of the packet */
1313 outw( PTR_READ | PTR_RCV | PTR_AUTOINC, ioaddr + POINTER );
1315 /* First two words are status and packet_length */
1316 status =inw( ioaddr + DATA_1 );
1317 packet_length =inw( ioaddr + DATA_1 );
1319 packet_length &=0x07ff;/* mask off top bits */
1321 PRINTK2(("RCV: STATUS %4x LENGTH %4x\n", status, packet_length ));
1323 . the packet length contains 3 extra words :
1324 . status, length, and an extra word with an odd byte .
1326 packet_length -=6;
1328 if( !(status & RS_ERRORS ) ){
1329 /* do stuff to make a new packet */
1330 struct sk_buff * skb;
1331 byte * data;
1333 /* read one extra byte */
1334 if( status & RS_ODDFRAME )
1335 packet_length++;
1337 /* set multicast stats */
1338 if( status & RS_MULTICAST )
1339 lp->stats.multicast++;
1341 skb =dev_alloc_skb( packet_length +5);
1343 if( skb == NULL ) {
1344 printk(KERN_NOTICE CARDNAME
1345 ": Low memory, packet dropped.\n");
1346 lp->stats.rx_dropped++;
1350 ! This should work without alignment, but it could be
1351 ! in the worse case
1354 skb_reserve( skb,2);/* 16 bit alignment */
1356 skb->dev = dev;
1357 data =skb_put( skb, packet_length);
1359 #ifdef USE_32_BIT
1360 /* QUESTION: Like in the TX routine, do I want
1361 to send the DWORDs or the bytes first, or some
1362 mixture. A mixture might improve already slow PIO
1363 performance */
1364 PRINTK3((" Reading %d dwords (and %d bytes)\n",
1365 packet_length >>2, packet_length &3));
1366 insl(ioaddr + DATA_1 , data, packet_length >>2);
1367 /* read the left over bytes */
1368 insb( ioaddr + DATA_1, data + (packet_length &0xFFFFFC),
1369 packet_length &0x3);
1370 #else
1371 PRINTK3((" Reading %d words and %d byte(s)\n",
1372 (packet_length >>1), packet_length &1);
1373 if( packet_length &1)
1374 *(data++) =inb( ioaddr + DATA_1 );
1375 insw(ioaddr + DATA_1 , data, (packet_length +1) >>1);
1376 if( packet_length &1) {
1377 data += packet_length & ~1;
1378 *((data++) =inb( ioaddr + DATA_1 );
1380 #endif
1381 #if SMC_DEBUG > 2
1382 print_packet( data, packet_length );
1383 #endif
1385 skb->protocol =eth_type_trans(skb, dev );
1386 netif_rx(skb);
1387 lp->stats.rx_packets++;
1388 }else{
1389 /* error ... */
1390 lp->stats.rx_errors++;
1392 if( status & RS_ALGNERR ) lp->stats.rx_frame_errors++;
1393 if( status & (RS_TOOSHORT | RS_TOOLONG ) )
1394 lp->stats.rx_length_errors++;
1395 if( status & RS_BADCRC) lp->stats.rx_crc_errors++;
1397 /* error or good, tell the card to get rid of this packet */
1398 outw( MC_RELEASE, ioaddr + MMU_CMD );
1401 return;
1405 /*************************************************************************
1406 . smc_tx
1408 . Purpose: Handle a transmit error message. This will only be called
1409 . when an error, because of the AUTO_RELEASE mode.
1411 . Algorithm:
1412 . Save pointer and packet no
1413 . Get the packet no from the top of the queue
1414 . check if it's valid ( if not, is this an error??? )
1415 . read the status word
1416 . record the error
1417 . ( resend? Not really, since we don't want old packets around )
1418 . Restore saved values
1419 ************************************************************************/
1420 static voidsmc_tx(struct net_device * dev )
1422 int ioaddr = dev->base_addr;
1423 struct smc_local *lp = (struct smc_local *)dev->priv;
1424 byte saved_packet;
1425 byte packet_no;
1426 word tx_status;
1429 /* assume bank 2 */
1431 saved_packet =inb( ioaddr + PNR_ARR );
1432 packet_no =inw( ioaddr + FIFO_PORTS );
1433 packet_no &=0x7F;
1435 /* select this as the packet to read from */
1436 outb( packet_no, ioaddr + PNR_ARR );
1438 /* read the first word from this packet */
1439 outw( PTR_AUTOINC | PTR_READ, ioaddr + POINTER );
1441 tx_status =inw( ioaddr + DATA_1 );
1442 PRINTK3((CARDNAME": TX DONE STATUS: %4x\n", tx_status ));
1444 lp->stats.tx_errors++;
1445 if( tx_status & TS_LOSTCAR ) lp->stats.tx_carrier_errors++;
1446 if( tx_status & TS_LATCOL ) {
1447 printk(KERN_DEBUG CARDNAME
1448 ": Late collision occurred on last xmit.\n");
1449 lp->stats.tx_window_errors++;
1451 #if 0
1452 if( tx_status & TS_16COL ) { ... }
1453 #endif
1455 if( tx_status & TS_SUCCESS ) {
1456 printk(CARDNAME": Successful packet caused interrupt\n");
1458 /* re-enable transmit */
1459 SMC_SELECT_BANK(0);
1460 outw(inw( ioaddr + TCR ) | TCR_ENABLE, ioaddr + TCR );
1462 /* kill the packet */
1463 SMC_SELECT_BANK(2);
1464 outw( MC_FREEPKT, ioaddr + MMU_CMD );
1466 /* one less packet waiting for me */
1467 lp->packets_waiting--;
1469 outb( saved_packet, ioaddr + PNR_ARR );
1470 return;
1473 /*----------------------------------------------------
1474 . smc_close
1476 . this makes the board clean up everything that it can
1477 . and not talk to the outside world. Caused by
1478 . an 'ifconfig ethX down'
1480 -----------------------------------------------------*/
1481 static intsmc_close(struct net_device *dev)
1483 netif_stop_queue(dev);
1484 /* clear everything */
1485 smc_shutdown( dev->base_addr );
1487 /* Update the statistics here. */
1488 return0;
1491 /*------------------------------------------------------------
1492 . Get the current statistics.
1493 . This may be called with the card open or closed.
1494 .-------------------------------------------------------------*/
1495 static struct net_device_stats*smc_query_statistics(struct net_device *dev) {
1496 struct smc_local *lp = (struct smc_local *)dev->priv;
1498 return&lp->stats;
1501 /*-----------------------------------------------------------
1502 . smc_set_multicast_list
1504 . This routine will, depending on the values passed to it,
1505 . either make it accept multicast packets, go into
1506 . promiscuous mode ( for TCPDUMP and cousins ) or accept
1507 . a select set of multicast packets
1509 static voidsmc_set_multicast_list(struct net_device *dev)
1511 short ioaddr = dev->base_addr;
1513 SMC_SELECT_BANK(0);
1514 if( dev->flags & IFF_PROMISC )
1515 outw(inw(ioaddr + RCR ) | RCR_PROMISC, ioaddr + RCR );
1517 /* BUG? I never disable promiscuous mode if multicasting was turned on.
1518 Now, I turn off promiscuous mode, but I don't do anything to multicasting
1519 when promiscuous mode is turned on.
1522 /* Here, I am setting this to accept all multicast packets.
1523 I don't need to zero the multicast table, because the flag is
1524 checked before the table is
1526 else if(dev->flags & IFF_ALLMULTI)
1527 outw(inw(ioaddr + RCR ) | RCR_ALMUL, ioaddr + RCR );
1529 /* We just get all multicast packets even if we only want them
1530 . from one source. This will be changed at some future
1531 . point. */
1532 else if(dev->mc_count ) {
1533 /* support hardware multicasting */
1535 /* be sure I get rid of flags I might have set */
1536 outw(inw( ioaddr + RCR ) & ~(RCR_PROMISC | RCR_ALMUL),
1537 ioaddr + RCR );
1538 /* NOTE: this has to set the bank, so make sure it is the
1539 last thing called. The bank is set to zero at the top */
1540 smc_setmulticast( ioaddr, dev->mc_count, dev->mc_list );
1542 else{
1543 outw(inw( ioaddr + RCR ) & ~(RCR_PROMISC | RCR_ALMUL),
1544 ioaddr + RCR );
1547 since I'm disabling all multicast entirely, I need to
1548 clear the multicast list
1550 SMC_SELECT_BANK(3);
1551 outw(0, ioaddr + MULTICAST1 );
1552 outw(0, ioaddr + MULTICAST2 );
1553 outw(0, ioaddr + MULTICAST3 );
1554 outw(0, ioaddr + MULTICAST4 );
1558 #ifdef MODULE
1560 static struct net_device devSMC9194;
1561 static int io;
1562 static int irq;
1563 static int ifport;
1565 MODULE_PARM(io,"i");
1566 MODULE_PARM(irq,"i");
1567 MODULE_PARM(ifport,"i");
1569 intinit_module(void)
1571 int result;
1573 if(io ==0)
1574 printk(KERN_WARNING
1575 CARDNAME": You shouldn't use auto-probing with insmod!\n");
1577 /* copy the parameters from insmod into the device structure */
1578 devSMC9194.base_addr = io;
1579 devSMC9194.irq = irq;
1580 devSMC9194.if_port = ifport;
1581 devSMC9194.init = smc_init;
1582 if((result =register_netdev(&devSMC9194)) !=0)
1583 return result;
1585 return0;
1588 voidcleanup_module(void)
1590 /* No need to check MOD_IN_USE, as sys_delete_module() checks. */
1591 unregister_netdev(&devSMC9194);
1593 free_irq(devSMC9194.irq, &devSMC9194);
1594 release_region(devSMC9194.base_addr, SMC_IO_EXTENT);
1596 if(devSMC9194.priv)
1597 kfree(devSMC9194.priv);
1600 #endif/* MODULE */
close