1 /*------------------------------------------------------------------------
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 )
15 . io = for the base address
17 . ifport = 0 for autodetect, 1 for TP, 2 for AUI ( or 10base2 )
20 . Erik Stahlman ( erik@vt.edu )
22 . Hardware multicast code from Peter Cammaert ( pc@denkart.be )
26 . o skeleton.c by Donald Becker ( becker@cesdis.gsfc.nasa.gov )
27 . o ( a LOT of advice from Becker as well )
30 . 12/07/95 Erik Stahlman written, got receive/xmit handled
31 . 01/03/96 Erik Stahlman worked out some bugs, actually usable!!! :-)
32 . 01/06/96 Erik Stahlman cleaned up some, better testing, etc
33 . 01/29/96 Erik Stahlman fixed autoirq, added multicast
34 . 02/01/96 Erik Stahlman 1. disabled all interrupts in smc_reset
35 . 2. got rid of post-decrementing bug -- UGH.
36 . 02/13/96 Erik Stahlman Tried to fix autoirq failure. Added more
37 . descriptive error messages.
38 . 02/15/96 Erik Stahlman Fixed typo that caused detection failure
39 . 02/23/96 Erik Stahlman Modified it to fit into kernel tree
40 . Added support to change hardware address
41 . Cleared stats on opens
42 . 02/26/96 Erik Stahlman Trial support for Kernel 1.2.13
43 . Kludge for automatic IRQ detection
44 . 03/04/96 Erik Stahlman Fixed kernel 1.3.70 +
45 . Fixed bug reported by Gardner Buchanan in
46 . smc_enable, with outw instead of outb
47 . 03/06/96 Erik Stahlman Added hardware multicast from Peter Cammaert
48 ----------------------------------------------------------------------------*/
50 static const char *version
=
51 "smc9194.c:v0.12 03/06/96 by Erik Stahlman (erik@vt.edu)\n";
54 #include <linux/module.h>
55 #include <linux/version.h>
58 #include <linux/kernel.h>
59 #include <linux/sched.h>
60 #include <linux/types.h>
61 #include <linux/fcntl.h>
62 #include <linux/interrupt.h>
63 #include <linux/ptrace.h>
64 #include <linux/ioport.h>
66 #include <linux/malloc.h>
67 #include <linux/string.h>
68 #include <linux/init.h>
69 #include <asm/bitops.h>
71 #include <linux/errno.h>
73 #include <linux/netdevice.h>
74 #include <linux/etherdevice.h>
75 #include <linux/skbuff.h>
78 /*------------------------------------------------------------------------
80 . Configuration options, for the experienced user to change.
82 -------------------------------------------------------------------------*/
85 . this is for kernels > 1.2.70
87 #define REALLY_NEW_KERNEL
88 #ifndef REALLY_NEW_KERNEL
89 #define free_irq( x, y ) free_irq( x )
90 #define request_irq( x, y, z, u, v ) request_irq( x, y, z, u )
94 . Do you want to use this with old kernels.
95 . WARNING: this is not well tested.
96 #define SUPPORT_OLD_KERNEL
101 . Do you want to use 32 bit xfers? This should work on all chips, as
102 . the chipset is designed to accommodate them.
107 .the SMC9194 can be at any of the following port addresses. To change,
108 .for a slightly different card, you can add it to the array. Keep in
109 .mind that the array must end in zero.
111 static unsigned int smc_portlist
[] __initdata
=
112 { 0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0,
113 0x300, 0x320, 0x340, 0x360, 0x380, 0x3A0, 0x3C0, 0x3E0, 0};
116 . Wait time for memory to be free. This probably shouldn't be
117 . tuned that much, as waiting for this means nothing else happens
120 #define MEMORY_WAIT_TIME 16
125 . 0 for normal operation
126 . 1 for slightly more details
127 . >2 for various levels of increasingly useless information
128 . 2 for interrupt tracking, status flags
129 . 3 for packet dumps, etc.
134 #define PRINTK3(x) printk x
140 #define PRINTK2(x) printk x
146 #define PRINTK(x) printk x
152 /* the older versions of the kernel cannot support autoprobing */
153 #ifdef SUPPORT_OLD_KERNEL
158 /*------------------------------------------------------------------------
160 . The internal workings of the driver. If you are changing anything
161 . here with the SMC stuff, you should have the datasheet and known
162 . what you are doing.
164 -------------------------------------------------------------------------*/
165 #define CARDNAME "SMC9194"
167 #ifdef SUPPORT_OLD_KERNEL
168 char kernel_version
[] = UTS_RELEASE
;
171 /* store this information for the driver.. */
174 these are things that the kernel wants me to keep, so users
175 can find out semi-useless statistics of how well the card is
178 struct net_device_stats stats
;
181 If I have to wait until memory is available to send
182 a packet, I will store the skbuff here, until I get the
183 desired memory. Then, I'll send it out and free it.
185 struct sk_buff
* saved_skb
;
188 . This keeps track of how many packets that I have
189 . sent out. When an TX_EMPTY interrupt comes, I know
190 . that all of these have been sent.
196 /*-----------------------------------------------------------------
198 . The driver can be entered at any of the following entry points.
200 .------------------------------------------------------------------ */
203 . This is called by register_netdev(). It is responsible for
204 . checking the portlist for the SMC9000 series chipset. If it finds
205 . one, then it will initialize the device, find the hardware information,
206 . and sets up the appropriate device parameters.
207 . NOTE: Interrupts are *OFF* when this procedure is called.
209 . NB:This shouldn't be static since it is referred to externally.
211 int smc_init(struct net_device
*dev
);
214 . The kernel calls this function when someone wants to use the device,
215 . typically 'ifconfig ethX up'.
217 static int smc_open(struct net_device
*dev
);
220 . This is called by the kernel to send a packet out into the net. it's
221 . responsible for doing a best-effort send, but if it's simply not possible
222 . to send it, the packet gets dropped.
224 static int smc_send_packet(struct sk_buff
*skb
, struct net_device
*dev
);
227 . This is called by the kernel in response to 'ifconfig ethX down'. It
228 . is responsible for cleaning up everything that the open routine
229 . does, and maybe putting the card into a powerdown state.
231 static int smc_close(struct net_device
*dev
);
234 . This routine allows the proc file system to query the driver's
237 static struct net_device_stats
* smc_query_statistics( struct net_device
*dev
);
240 . Finally, a call to set promiscuous mode ( for TCPDUMP and related
241 . programs ) and multicast modes.
243 #ifdef SUPPORT_OLD_KERNEL
244 static void smc_set_multicast_list(struct net_device
*dev
, int num_addrs
,
247 static void smc_set_multicast_list(struct net_device
*dev
);
250 /*---------------------------------------------------------------
252 . Interrupt level calls..
254 ----------------------------------------------------------------*/
257 . Handles the actual interrupt
259 #ifdef REALLY_NEW_KERNEL
260 static void smc_interrupt(int irq
, void *, struct pt_regs
*regs
);
262 static void smc_interrupt(int irq
, struct pt_regs
*regs
);
265 . This is a separate procedure to handle the receipt of a packet, to
266 . leave the interrupt code looking slightly cleaner
268 inline static void smc_rcv( struct net_device
*dev
);
270 . This handles a TX interrupt, which is only called when an error
271 . relating to a packet is sent.
273 inline static void smc_tx( struct net_device
* dev
);
276 ------------------------------------------------------------
280 ------------------------------------------------------------
284 . Test if a given location contains a chip, trying to cause as
285 . little damage as possible if it's not a SMC chip.
287 static int smc_probe( int ioaddr
);
290 . this routine initializes the cards hardware, prints out the configuration
291 . to the system log as well as the vanity message, and handles the setup
292 . of a device parameter.
293 . It will give an error if it can't initialize the card.
295 static int smc_initcard( struct net_device
*, int ioaddr
);
298 . A rather simple routine to print out a packet for debugging purposes.
301 static void print_packet( byte
*, int );
304 #define tx_done(dev) 1
306 /* this is called to actually send the packet to the chip */
307 static void smc_hardware_send_packet( struct net_device
* dev
);
309 /* Since I am not sure if I will have enough room in the chip's ram
310 . to store the packet, I call this routine, which either sends it
311 . now, or generates an interrupt when the card is ready for the
313 static int smc_wait_to_send_packet( struct sk_buff
* skb
, struct net_device
*dev
);
315 /* this does a soft reset on the device */
316 static void smc_reset( int ioaddr
);
318 /* Enable Interrupts, Receive, and Transmit */
319 static void smc_enable( int ioaddr
);
321 /* this puts the device in an inactive state */
322 static void smc_shutdown( int ioaddr
);
325 /* This routine will find the IRQ of the driver if one is not
326 . specified in the input to the device. */
327 static int smc_findirq( int ioaddr
);
331 this routine will set the hardware multicast table to the specified
332 values given it by the higher level routines
334 #ifndef SUPPORT_OLD_KERNEL
335 static void smc_setmulticast( int ioaddr
, int count
, struct dev_mc_list
* );
336 static int crc32( char *, int );
339 #ifdef SUPPORT_OLD_KERNEL
340 extern struct net_device
*init_etherdev(struct net_device
*dev
, int sizeof_private
,
341 unsigned long *mem_startp
);
345 . Function: smc_reset( int ioaddr )
347 . This sets the SMC91xx chip to its normal state, hopefully from whatever
348 . mess that any other DOS driver has put it in.
350 . Maybe I should reset more registers to defaults in here? SOFTRESET should
354 . 1. send a SOFT RESET
355 . 2. wait for it to finish
356 . 3. enable autorelease mode
357 . 4. reset the memory management unit
358 . 5. clear all interrupts
361 static void smc_reset( int ioaddr
)
363 /* This resets the registers mostly to defaults, but doesn't
364 affect EEPROM. That seems unnecessary */
365 SMC_SELECT_BANK( 0 );
366 outw( RCR_SOFTRESET
, ioaddr
+ RCR
);
368 /* this should pause enough for the chip to be happy */
371 /* Set the transmit and receive configuration registers to
373 outw( RCR_CLEAR
, ioaddr
+ RCR
);
374 outw( TCR_CLEAR
, ioaddr
+ TCR
);
376 /* set the control register to automatically
377 release successfully transmitted packets, to make the best
378 use out of our limited memory */
379 SMC_SELECT_BANK( 1 );
380 outw( inw( ioaddr
+ CONTROL
) | CTL_AUTO_RELEASE
, ioaddr
+ CONTROL
);
383 SMC_SELECT_BANK( 2 );
384 outw( MC_RESET
, ioaddr
+ MMU_CMD
);
386 /* Note: It doesn't seem that waiting for the MMU busy is needed here,
387 but this is a place where future chipsets _COULD_ break. Be wary
388 of issuing another MMU command right after this */
390 outb( 0, ioaddr
+ INT_MASK
);
394 . Function: smc_enable
395 . Purpose: let the chip talk to the outside work
397 . 1. Enable the transmitter
398 . 2. Enable the receiver
399 . 3. Enable interrupts
401 static void smc_enable( int ioaddr
)
403 SMC_SELECT_BANK( 0 );
404 /* see the header file for options in TCR/RCR NORMAL*/
405 outw( TCR_NORMAL
, ioaddr
+ TCR
);
406 outw( RCR_NORMAL
, ioaddr
+ RCR
);
408 /* now, enable interrupts */
409 SMC_SELECT_BANK( 2 );
410 outb( SMC_INTERRUPT_MASK
, ioaddr
+ INT_MASK
);
414 . Function: smc_shutdown
415 . Purpose: closes down the SMC91xxx chip.
417 . 1. zero the interrupt mask
418 . 2. clear the enable receive flag
419 . 3. clear the enable xmit flags
422 . (1) maybe utilize power down mode.
423 . Why not yet? Because while the chip will go into power down mode,
424 . the manual says that it will wake up in response to any I/O requests
425 . in the register space. Empirical results do not show this working.
427 static void smc_shutdown( int ioaddr
)
429 /* no more interrupts for me */
430 SMC_SELECT_BANK( 2 );
431 outb( 0, ioaddr
+ INT_MASK
);
433 /* and tell the card to stay away from that nasty outside world */
434 SMC_SELECT_BANK( 0 );
435 outb( RCR_CLEAR
, ioaddr
+ RCR
);
436 outb( TCR_CLEAR
, ioaddr
+ TCR
);
438 /* finally, shut the chip down */
439 SMC_SELECT_BANK( 1 );
440 outw( inw( ioaddr
+ CONTROL
), CTL_POWERDOWN
, ioaddr
+ CONTROL
);
445 #ifndef SUPPORT_OLD_KERNEL
447 . Function: smc_setmulticast( int ioaddr, int count, dev_mc_list * adds )
449 . This sets the internal hardware table to filter out unwanted multicast
450 . packets before they take up memory.
452 . The SMC chip uses a hash table where the high 6 bits of the CRC of
453 . address are the offset into the table. If that bit is 1, then the
454 . multicast packet is accepted. Otherwise, it's dropped silently.
456 . To use the 6 bits as an offset into the table, the high 3 bits are the
457 . number of the 8 bit register, while the low 3 bits are the bit within
460 . This routine is based very heavily on the one provided by Peter Cammaert.
464 static void smc_setmulticast( int ioaddr
, int count
, struct dev_mc_list
* addrs
) {
466 unsigned char multicast_table
[ 8 ];
467 struct dev_mc_list
* cur_addr
;
468 /* table for flipping the order of 3 bits */
469 unsigned char invert3
[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
471 /* start with a table of all zeros: reject all */
472 memset( multicast_table
, 0, sizeof( multicast_table
) );
475 for ( i
= 0; i
< count
; i
++, cur_addr
= cur_addr
->next
) {
478 /* do we have a pointer here? */
481 /* make sure this is a multicast address - shouldn't this
482 be a given if we have it here ? */
483 if ( !( *cur_addr
->dmi_addr
& 1 ) )
486 /* only use the low order bits */
487 position
= crc32( cur_addr
->dmi_addr
, 6 ) & 0x3f;
489 /* do some messy swapping to put the bit in the right spot */
490 multicast_table
[invert3
[position
&7]] |=
491 (1<<invert3
[(position
>>3)&7]);
494 /* now, the table can be loaded into the chipset */
495 SMC_SELECT_BANK( 3 );
497 for ( i
= 0; i
< 8 ; i
++ ) {
498 outb( multicast_table
[i
], ioaddr
+ MULTICAST1
+ i
);
503 Finds the CRC32 of a set of bytes.
504 Again, from Peter Cammaert's code.
506 static int crc32( char * s
, int length
) {
510 /* crc polynomial for Ethernet */
511 const unsigned long poly
= 0xedb88320;
512 /* crc value - preinitialized to all 1's */
513 unsigned long crc_value
= 0xffffffff;
515 for ( perByte
= 0; perByte
< length
; perByte
++ ) {
519 for ( perBit
= 0; perBit
< 8; perBit
++ ) {
520 crc_value
= (crc_value
>>1)^
521 (((crc_value
^c
)&0x01)?poly
:0);
532 . Function: smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * )
534 . Attempt to allocate memory for a packet, if chip-memory is not
535 . available, then tell the card to generate an interrupt when it
540 . o if the saved_skb is not currently null, then drop this packet
541 . on the floor. This should never happen, because of TBUSY.
542 . o if the saved_skb is null, then replace it with the current packet,
543 . o See if I can sending it now.
544 . o (NO): Enable interrupts and let the interrupt handler deal with it.
545 . o (YES):Send it now.
547 static int smc_wait_to_send_packet( struct sk_buff
* skb
, struct net_device
* dev
)
549 struct smc_local
*lp
= (struct smc_local
*)dev
->priv
;
550 unsigned short ioaddr
= dev
->base_addr
;
552 unsigned short numPages
;
555 if ( lp
->saved_skb
) {
556 /* THIS SHOULD NEVER HAPPEN. */
557 lp
->stats
.tx_aborted_errors
++;
558 printk(CARDNAME
": Bad Craziness - sent packet while busy.\n" );
563 length
= ETH_ZLEN
< skb
->len
? skb
->len
: ETH_ZLEN
;
566 . the MMU wants the number of pages to be the number of 256 bytes
567 . 'pages', minus 1 ( since a packet can't ever have 0 pages :) )
569 numPages
= length
/ 256;
572 printk(CARDNAME
": Far too big packet error. \n");
573 /* freeing the packet is a good thing here... but should
574 . any packets of this size get down here? */
576 lp
->saved_skb
= NULL
;
577 /* this IS an error, but, i don't want the skb saved */
580 /* either way, a packet is waiting now */
581 lp
->packets_waiting
++;
583 /* now, try to allocate the memory */
584 SMC_SELECT_BANK( 2 );
585 outw( MC_ALLOC
| numPages
, ioaddr
+ MMU_CMD
);
589 . wait a short amount of time.. if I can send a packet now, I send
590 . it now. Otherwise, I enable an interrupt and wait for one to be
593 . I could have handled this a slightly different way, by checking to
594 . see if any memory was available in the FREE MEMORY register. However,
595 . either way, I need to generate an allocation, and the allocation works
596 . no matter what, so I saw no point in checking free memory.
598 time_out
= MEMORY_WAIT_TIME
;
602 status
= inb( ioaddr
+ INTERRUPT
);
603 if ( status
& IM_ALLOC_INT
) {
604 /* acknowledge the interrupt */
605 outb( IM_ALLOC_INT
, ioaddr
+ INTERRUPT
);
608 } while ( -- time_out
);
611 /* oh well, wait until the chip finds memory later */
612 SMC_ENABLE_INT( IM_ALLOC_INT
);
613 PRINTK2((CARDNAME
": memory allocation deferred. \n"));
614 /* it's deferred, but I'll handle it later */
617 /* or YES! I can send the packet now.. */
618 smc_hardware_send_packet(dev
);
624 . Function: smc_hardware_send_packet(struct net_device * )
626 . This sends the actual packet to the SMC9xxx chip.
629 . First, see if a saved_skb is available.
630 . ( this should NOT be called if there is no 'saved_skb'
631 . Now, find the packet number that the chip allocated
632 . Point the data pointers at it in memory
633 . Set the length word in the chip's memory
634 . Dump the packet to chip memory
635 . Check if a last byte is needed ( odd length packet )
636 . if so, set the control flag right
637 . Tell the card to send it
638 . Enable the transmit interrupt, so I know if it failed
639 . Free the kernel data if I actually sent it.
641 static void smc_hardware_send_packet( struct net_device
* dev
)
643 struct smc_local
*lp
= (struct smc_local
*)dev
->priv
;
645 struct sk_buff
* skb
= lp
->saved_skb
;
647 unsigned short ioaddr
;
650 ioaddr
= dev
->base_addr
;
653 PRINTK((CARDNAME
": In XMIT with no packet to send \n"));
656 length
= ETH_ZLEN
< skb
->len
? skb
->len
: ETH_ZLEN
;
659 /* If I get here, I _know_ there is a packet slot waiting for me */
660 packet_no
= inb( ioaddr
+ PNR_ARR
+ 1 );
661 if ( packet_no
& 0x80 ) {
662 /* or isn't there? BAD CHIP! */
663 printk(KERN_DEBUG CARDNAME
": Memory allocation failed. \n");
665 lp
->saved_skb
= NULL
;
670 /* we have a packet address, so tell the card to use it */
671 outb( packet_no
, ioaddr
+ PNR_ARR
);
673 /* point to the beginning of the packet */
674 outw( PTR_AUTOINC
, ioaddr
+ POINTER
);
676 PRINTK3((CARDNAME
": Trying to xmit packet of length %x\n", length
));
678 print_packet( buf
, length
);
681 /* send the packet length ( +6 for status, length and ctl byte )
682 and the status word ( set to zeros ) */
684 outl( (length
+6 ) << 16 , ioaddr
+ DATA_1
);
686 outw( 0, ioaddr
+ DATA_1
);
687 /* send the packet length ( +6 for status words, length, and ctl*/
688 outb( (length
+6) & 0xFF,ioaddr
+ DATA_1
);
689 outb( (length
+6) >> 8 , ioaddr
+ DATA_1
);
692 /* send the actual data
693 . I _think_ it's faster to send the longs first, and then
694 . mop up by sending the last word. It depends heavily
695 . on alignment, at least on the 486. Maybe it would be
696 . a good idea to check which is optimal? But that could take
697 . almost as much time as is saved?
700 if ( length
& 0x2 ) {
701 outsl(ioaddr
+ DATA_1
, buf
, length
>> 2 );
702 outw( *((word
*)(buf
+ (length
& 0xFFFFFFFC))),ioaddr
+DATA_1
);
705 outsl(ioaddr
+ DATA_1
, buf
, length
>> 2 );
707 outsw(ioaddr
+ DATA_1
, buf
, (length
) >> 1);
709 /* Send the last byte, if there is one. */
711 if ( (length
& 1) == 0 ) {
712 outw( 0, ioaddr
+ DATA_1
);
714 outb( buf
[length
-1 ], ioaddr
+ DATA_1
);
715 outb( 0x20, ioaddr
+ DATA_1
);
718 /* enable the interrupts */
719 SMC_ENABLE_INT( (IM_TX_INT
| IM_TX_EMPTY_INT
) );
721 /* and let the chipset deal with it */
722 outw( MC_ENQUEUE
, ioaddr
+ MMU_CMD
);
724 PRINTK2((CARDNAME
": Sent packet of length %d \n",length
));
726 lp
->saved_skb
= NULL
;
729 dev
->trans_start
= jiffies
;
731 /* we can send another packet */
738 /*-------------------------------------------------------------------------
740 | smc_init( struct net_device * dev )
742 | dev->base_addr == 0, try to find all possible locations
743 | dev->base_addr == 1, return failure code
744 | dev->base_addr == 2, always allocate space, and return success
745 | dev->base_addr == <anything else> this is the address to check
748 | 0 --> there is a device
749 | anything else, error
751 ---------------------------------------------------------------------------
753 int __init
smc_init(struct net_device
*dev
)
756 int base_addr
= dev
? dev
->base_addr
: 0;
758 /* try a specific location */
759 if (base_addr
> 0x1ff) {
761 error
= smc_probe(base_addr
);
763 return smc_initcard( dev
, base_addr
);
767 if ( 0 != base_addr
) {
772 /* check every ethernet address */
773 for (i
= 0; smc_portlist
[i
]; i
++) {
774 int ioaddr
= smc_portlist
[i
];
776 /* check if the area is available */
777 if (check_region( ioaddr
, SMC_IO_EXTENT
))
780 /* check this specific address */
781 if ( smc_probe( ioaddr
) == 0) {
782 return smc_initcard( dev
, ioaddr
);
786 /* couldn't find anything */
791 /*----------------------------------------------------------------------
794 . This routine has a simple purpose -- make the SMC chip generate an
795 . interrupt, so an auto-detect routine can detect it, and find the IRQ,
796 ------------------------------------------------------------------------
798 int __init
smc_findirq( int ioaddr
)
803 /* I have to do a STI() here, because this is called from
804 a routine that does an CLI during this process, making it
805 rather difficult to get interrupts for auto detection */
811 * What I try to do here is trigger an ALLOC_INT. This is done
812 * by allocating a small chunk of memory, which will give an interrupt
818 /* enable ALLOCation interrupts ONLY */
819 outb( IM_ALLOC_INT
, ioaddr
+ INT_MASK
);
822 . Allocate 512 bytes of memory. Note that the chip was just
823 . reset so all the memory is available
825 outw( MC_ALLOC
| 1, ioaddr
+ MMU_CMD
);
828 . Wait until positive that the interrupt has been generated
833 int_status
= inb( ioaddr
+ INTERRUPT
);
835 if ( int_status
& IM_ALLOC_INT
)
836 break; /* got the interrupt */
839 /* there is really nothing that I can do here if timeout fails,
840 as autoirq_report will return a 0 anyway, which is what I
841 want in this case. Plus, the clean up is needed in both
845 On a fast machine, the status might change before the interrupt
846 is given to the processor. This means that the interrupt was
847 never detected, and autoirq_report fails to report anything.
848 This should fix autoirq_* problems.
853 /* and disable all interrupts again */
854 outb( 0, ioaddr
+ INT_MASK
);
856 /* clear hardware interrupts again, because that's how it
857 was when I was called... */
860 /* and return what I found */
861 return autoirq_report( 0 );
865 /*----------------------------------------------------------------------
866 . Function: smc_probe( int ioaddr )
869 . Tests to see if a given ioaddr points to an SMC9xxx chip.
870 . Returns a 0 on success
873 . (1) see if the high byte of BANK_SELECT is 0x33
874 . (2) compare the ioaddr with the base register's address
875 . (3) see if I recognize the chip ID in the appropriate register
877 .---------------------------------------------------------------------
880 static int __init
smc_probe( int ioaddr
)
883 word revision_register
;
884 word base_address_register
;
886 /* First, see if the high byte is 0x33 */
887 bank
= inw( ioaddr
+ BANK_SELECT
);
888 if ( (bank
& 0xFF00) != 0x3300 ) {
891 /* The above MIGHT indicate a device, but I need to write to further
893 outw( 0x0, ioaddr
+ BANK_SELECT
);
894 bank
= inw( ioaddr
+ BANK_SELECT
);
895 if ( (bank
& 0xFF00 ) != 0x3300 ) {
898 /* well, we've already written once, so hopefully another time won't
899 hurt. This time, I need to switch the bank register to bank 1,
900 so I can access the base address register */
902 base_address_register
= inw( ioaddr
+ BASE
);
903 if ( ioaddr
!= ( base_address_register
>> 3 & 0x3E0 ) ) {
904 printk(CARDNAME
": IOADDR %x doesn't match configuration (%x)."
905 "Probably not a SMC chip\n",
906 ioaddr
, base_address_register
>> 3 & 0x3E0 );
907 /* well, the base address register didn't match. Must not have
908 been a SMC chip after all. */
912 /* check if the revision register is something that I recognize.
913 These might need to be added to later, as future revisions
916 revision_register
= inw( ioaddr
+ REVISION
);
917 if ( !chip_ids
[ ( revision_register
>> 4 ) & 0xF ] ) {
918 /* I don't recognize this chip, so... */
919 printk(CARDNAME
": IO %x: Unrecognized revision register:"
920 " %x, Contact author. \n", ioaddr
, revision_register
);
925 /* at this point I'll assume that the chip is an SMC9xxx.
926 It might be prudent to check a listing of MAC addresses
927 against the hardware address, or do some other tests. */
931 /*---------------------------------------------------------------
932 . Here I do typical initialization tasks.
934 . o Initialize the structure if needed
935 . o print out my vanity message if not done so already
936 . o print out what type of hardware is detected
937 . o print out the ethernet address
939 . o set up my private data
940 . o configure the dev structure with my subroutines
941 . o actually GRAB the irq.
943 .-----------------------------------------------------------------
945 static int __init
smc_initcard(struct net_device
*dev
, int ioaddr
)
949 static unsigned version_printed
= 0;
952 word revision_register
;
953 word configuration_register
;
954 word memory_info_register
;
955 word memory_cfg_register
;
957 const char * version_string
;
958 const char * if_string
;
963 /* see if I need to initialize the ethernet card structure */
965 #ifdef SUPPORT_OLD_KERNEL
967 /* note: the old module interface does not support this call */
968 dev
= init_etherdev( 0, sizeof( struct smc_local
), 0 );
971 dev
= init_etherdev(0, 0);
977 if (version_printed
++ == 0)
978 printk("%s", version
);
980 /* fill in some of the fields */
981 dev
->base_addr
= ioaddr
;
984 . Get the MAC address ( bank 1, regs 4 - 9 )
986 SMC_SELECT_BANK( 1 );
987 for ( i
= 0; i
< 6; i
+= 2 ) {
990 address
= inw( ioaddr
+ ADDR0
+ i
);
991 dev
->dev_addr
[ i
+ 1] = address
>> 8;
992 dev
->dev_addr
[ i
] = address
& 0xFF;
995 /* get the memory information */
997 SMC_SELECT_BANK( 0 );
998 memory_info_register
= inw( ioaddr
+ MIR
);
999 memory_cfg_register
= inw( ioaddr
+ MCR
);
1000 memory
= ( memory_cfg_register
>> 9 ) & 0x7; /* multiplier */
1001 memory
*= 256 * ( memory_info_register
& 0xFF );
1004 Now, I want to find out more about the chip. This is sort of
1005 redundant, but it's cleaner to have it in both, rather than having
1006 one VERY long probe procedure.
1009 revision_register
= inw( ioaddr
+ REVISION
);
1010 version_string
= chip_ids
[ ( revision_register
>> 4 ) & 0xF ];
1011 if ( !version_string
) {
1012 /* I shouldn't get here because this call was done before.... */
1016 /* is it using AUI or 10BaseT ? */
1017 if ( dev
->if_port
== 0 ) {
1019 configuration_register
= inw( ioaddr
+ CONFIG
);
1020 if ( configuration_register
& CFG_AUI_SELECT
)
1025 if_string
= interfaces
[ dev
->if_port
- 1 ];
1027 /* now, reset the chip, and put it into a known state */
1028 smc_reset( ioaddr
);
1031 . If dev->irq is 0, then the device has to be banged on to see
1034 . This banging doesn't always detect the IRQ, for unknown reasons.
1035 . a workaround is to reset the chip and try again.
1037 . Interestingly, the DOS packet driver *SETS* the IRQ on the card to
1038 . be what is requested on the command line. I don't do that, mostly
1039 . because the card that I have uses a non-standard method of accessing
1040 . the IRQs, and because this _should_ work in most configurations.
1042 . Specifying an IRQ is done with the assumption that the user knows
1043 . what (s)he is doing. No checking is done!!!!
1046 #ifndef NO_AUTOPROBE
1047 if ( dev
->irq
< 2 ) {
1051 while ( trials
-- ) {
1052 dev
->irq
= smc_findirq( ioaddr
);
1055 /* kick the card and try again */
1056 smc_reset( ioaddr
);
1059 if (dev
->irq
== 0 ) {
1060 printk(CARDNAME
": Couldn't autodetect your IRQ. Use irq=xx.\n");
1064 if (dev
->irq
== 0 ) {
1066 ": Autoprobing IRQs is not supported for old kernels.\n");
1070 if (dev
->irq
== 2) {
1071 /* Fixup for users that don't know that IRQ 2 is really IRQ 9,
1072 * or don't know which one to set.
1077 /* now, print out the card info, in a short format.. */
1079 printk(CARDNAME
": %s(r:%d) at %#3x IRQ:%d INTF:%s MEM:%db ",
1080 version_string
, revision_register
& 0xF, ioaddr
, dev
->irq
,
1081 if_string
, memory
);
1083 . Print the Ethernet address
1086 for (i
= 0; i
< 5; i
++)
1087 printk("%2.2x:", dev
->dev_addr
[i
] );
1088 printk("%2.2x \n", dev
->dev_addr
[5] );
1091 /* Initialize the private structure. */
1092 if (dev
->priv
== NULL
) {
1093 dev
->priv
= kmalloc(sizeof(struct smc_local
), GFP_KERNEL
);
1094 if (dev
->priv
== NULL
)
1097 /* set the private data to zero by default */
1098 memset(dev
->priv
, 0, sizeof(struct smc_local
));
1100 /* Fill in the fields of the device structure with ethernet values. */
1104 irqval
= request_irq(dev
->irq
, &smc_interrupt
, 0, CARDNAME
, dev
);
1106 printk(CARDNAME
": unable to get IRQ %d (irqval=%d).\n",
1111 /* Grab the region so that no one else tries to probe our ioports. */
1112 request_region(ioaddr
, SMC_IO_EXTENT
, CARDNAME
);
1114 dev
->open
= smc_open
;
1115 dev
->stop
= smc_close
;
1116 dev
->hard_start_xmit
= smc_send_packet
;
1117 dev
->get_stats
= smc_query_statistics
;
1118 #ifdef HAVE_MULTICAST
1119 dev
->set_multicast_list
= &smc_set_multicast_list
;
1126 static void print_packet( byte
* buf
, int length
)
1133 printk("Packet of length %d \n", length
);
1134 lines
= length
/ 16;
1135 remainder
= length
% 16;
1137 for ( i
= 0; i
< lines
; i
++ ) {
1140 for ( cur
= 0; cur
< 8; cur
++ ) {
1145 printk("%02x%02x ", a
, b
);
1149 for ( i
= 0; i
< remainder
/2 ; i
++ ) {
1154 printk("%02x%02x ", a
, b
);
1163 * Open and Initialize the board
1165 * Set up everything, reset the card, etc ..
1168 static int smc_open(struct net_device
*dev
)
1170 int ioaddr
= dev
->base_addr
;
1172 int i
; /* used to set hw ethernet address */
1174 /* clear out all the junk that was put here before... */
1175 memset(dev
->priv
, 0, sizeof(struct smc_local
));
1184 /* reset the hardware */
1186 smc_reset( ioaddr
);
1187 smc_enable( ioaddr
);
1189 /* Select which interface to use */
1191 SMC_SELECT_BANK( 1 );
1192 if ( dev
->if_port
== 1 ) {
1193 outw( inw( ioaddr
+ CONFIG
) & ~CFG_AUI_SELECT
,
1196 else if ( dev
->if_port
== 2 ) {
1197 outw( inw( ioaddr
+ CONFIG
) | CFG_AUI_SELECT
,
1202 According to Becker, I have to set the hardware address
1203 at this point, because the (l)user can set it with an
1204 ioctl. Easily done...
1206 SMC_SELECT_BANK( 1 );
1207 for ( i
= 0; i
< 6; i
+= 2 ) {
1210 address
= dev
->dev_addr
[ i
+ 1 ] << 8 ;
1211 address
|= dev
->dev_addr
[ i
];
1212 outw( address
, ioaddr
+ ADDR0
+ i
);
1217 /*--------------------------------------------------------
1218 . Called by the kernel to send a packet out into the void
1219 . of the net. This routine is largely based on
1220 . skeleton.c, from Becker.
1221 .--------------------------------------------------------
1223 static int smc_send_packet(struct sk_buff
*skb
, struct net_device
*dev
)
1226 /* If we get here, some higher level has decided we are broken.
1227 There should really be a "kick me" function call instead. */
1228 int tickssofar
= jiffies
- dev
->trans_start
;
1231 printk(KERN_WARNING CARDNAME
": transmit timed out, %s?\n",
1232 tx_done(dev
) ? "IRQ conflict" :
1233 "network cable problem");
1234 /* "kick" the adaptor */
1235 smc_reset( dev
->base_addr
);
1236 smc_enable( dev
->base_addr
);
1239 dev
->trans_start
= jiffies
;
1240 /* clear anything saved */
1241 ((struct smc_local
*)dev
->priv
)->saved_skb
= NULL
;
1244 /* Block a timer-based transmit from overlapping. This could better be
1245 done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
1246 if (test_and_set_bit(0, (void*)&dev
->tbusy
) != 0) {
1247 printk(KERN_WARNING CARDNAME
": Transmitter access conflict.\n");
1248 dev_kfree_skb (skb
);
1250 /* Well, I want to send the packet.. but I don't know
1251 if I can send it right now... */
1252 return smc_wait_to_send_packet( skb
, dev
);
1257 /*--------------------------------------------------------------------
1259 . This is the main routine of the driver, to handle the device when
1260 . it needs some attention.
1263 . first, save state of the chipset
1264 . branch off into routines to handle each case, and acknowledge
1265 . each to the interrupt register
1266 . and finally restore state.
1268 ---------------------------------------------------------------------*/
1269 #ifdef REALLY_NEW_KERNEL
1270 static void smc_interrupt(int irq
, void * dev_id
, struct pt_regs
* regs
)
1272 static void smc_interrupt(int irq
, struct pt_regs
* regs
)
1275 struct net_device
*dev
= dev_id
;
1276 int ioaddr
= dev
->base_addr
;
1277 struct smc_local
*lp
= (struct smc_local
*)dev
->priv
;
1283 /* state registers */
1289 PRINTK3((CARDNAME
": SMC interrupt started \n"));
1292 printk(KERN_WARNING CARDNAME
": irq %d for unknown device.\n",
1297 /* will Linux let this happen ?? If not, this costs some speed */
1298 if ( dev
->interrupt
) {
1299 printk(KERN_WARNING CARDNAME
": interrupt inside interrupt.\n");
1305 saved_bank
= inw( ioaddr
+ BANK_SELECT
);
1308 saved_pointer
= inw( ioaddr
+ POINTER
);
1310 mask
= inb( ioaddr
+ INT_MASK
);
1311 /* clear all interrupts */
1312 outb( 0, ioaddr
+ INT_MASK
);
1315 /* set a timeout value, so I don't stay here forever */
1318 PRINTK2((KERN_WARNING CARDNAME
": MASK IS %x \n", mask
));
1320 /* read the status flag, and mask it */
1321 status
= inb( ioaddr
+ INTERRUPT
) & mask
;
1325 PRINTK3((KERN_WARNING CARDNAME
1326 ": Handling interrupt status %x \n", status
));
1328 if (status
& IM_RCV_INT
) {
1329 /* Got a packet(s). */
1330 PRINTK2((KERN_WARNING CARDNAME
1331 ": Receive Interrupt\n"));
1333 } else if (status
& IM_TX_INT
) {
1334 PRINTK2((KERN_WARNING CARDNAME
1335 ": TX ERROR handled\n"));
1337 outb(IM_TX_INT
, ioaddr
+ INTERRUPT
);
1338 } else if (status
& IM_TX_EMPTY_INT
) {
1340 SMC_SELECT_BANK( 0 );
1341 card_stats
= inw( ioaddr
+ COUNTER
);
1342 /* single collisions */
1343 lp
->stats
.collisions
+= card_stats
& 0xF;
1345 /* multiple collisions */
1346 lp
->stats
.collisions
+= card_stats
& 0xF;
1348 /* these are for when linux supports these statistics */
1353 /* excess deferred */
1355 SMC_SELECT_BANK( 2 );
1356 PRINTK2((KERN_WARNING CARDNAME
1357 ": TX_BUFFER_EMPTY handled\n"));
1358 outb( IM_TX_EMPTY_INT
, ioaddr
+ INTERRUPT
);
1359 mask
&= ~IM_TX_EMPTY_INT
;
1360 lp
->stats
.tx_packets
+= lp
->packets_waiting
;
1361 lp
->packets_waiting
= 0;
1363 } else if (status
& IM_ALLOC_INT
) {
1364 PRINTK2((KERN_DEBUG CARDNAME
1365 ": Allocation interrupt \n"));
1366 /* clear this interrupt so it doesn't happen again */
1367 mask
&= ~IM_ALLOC_INT
;
1369 smc_hardware_send_packet( dev
);
1371 /* enable xmit interrupts based on this */
1372 mask
|= ( IM_TX_EMPTY_INT
| IM_TX_INT
);
1374 /* and let the card send more packets to me */
1377 PRINTK2((CARDNAME
": Handoff done successfully.\n"));
1378 } else if (status
& IM_RX_OVRN_INT
) {
1379 lp
->stats
.rx_errors
++;
1380 lp
->stats
.rx_fifo_errors
++;
1381 outb( IM_RX_OVRN_INT
, ioaddr
+ INTERRUPT
);
1382 } else if (status
& IM_EPH_INT
) {
1383 PRINTK((CARDNAME
": UNSUPPORTED: EPH INTERRUPT \n"));
1384 } else if (status
& IM_ERCV_INT
) {
1385 PRINTK((CARDNAME
": UNSUPPORTED: ERCV INTERRUPT \n"));
1386 outb( IM_ERCV_INT
, ioaddr
+ INTERRUPT
);
1388 } while ( timeout
-- );
1391 /* restore state register */
1392 SMC_SELECT_BANK( 2 );
1393 outb( mask
, ioaddr
+ INT_MASK
);
1395 PRINTK3(( KERN_WARNING CARDNAME
": MASK is now %x \n", mask
));
1396 outw( saved_pointer
, ioaddr
+ POINTER
);
1398 SMC_SELECT_BANK( saved_bank
);
1401 PRINTK3((CARDNAME
": Interrupt done\n"));
1405 /*-------------------------------------------------------------
1407 . smc_rcv - receive a packet from the card
1409 . There is ( at least ) a packet waiting to be read from
1413 . o If an error, record it
1414 . o otherwise, read in the packet
1415 --------------------------------------------------------------
1417 static void smc_rcv(struct net_device
*dev
)
1419 struct smc_local
*lp
= (struct smc_local
*)dev
->priv
;
1420 int ioaddr
= dev
->base_addr
;
1427 packet_number
= inw( ioaddr
+ FIFO_PORTS
);
1429 if ( packet_number
& FP_RXEMPTY
) {
1430 /* we got called , but nothing was on the FIFO */
1431 PRINTK((CARDNAME
": WARNING: smc_rcv with nothing on FIFO. \n"));
1432 /* don't need to restore anything */
1436 /* start reading from the start of the packet */
1437 outw( PTR_READ
| PTR_RCV
| PTR_AUTOINC
, ioaddr
+ POINTER
);
1439 /* First two words are status and packet_length */
1440 status
= inw( ioaddr
+ DATA_1
);
1441 packet_length
= inw( ioaddr
+ DATA_1
);
1443 packet_length
&= 0x07ff; /* mask off top bits */
1445 PRINTK2(("RCV: STATUS %4x LENGTH %4x\n", status
, packet_length
));
1447 . the packet length contains 3 extra words :
1448 . status, length, and an extra word with an odd byte .
1452 if ( !(status
& RS_ERRORS
) ){
1453 /* do stuff to make a new packet */
1454 struct sk_buff
* skb
;
1457 /* read one extra byte */
1458 if ( status
& RS_ODDFRAME
)
1461 /* set multicast stats */
1462 if ( status
& RS_MULTICAST
)
1463 lp
->stats
.multicast
++;
1465 #ifdef SUPPORT_OLD_KERNEL
1466 skb
= alloc_skb( packet_length
+ 5, GFP_ATOMIC
);
1468 skb
= dev_alloc_skb( packet_length
+ 5);
1471 if ( skb
== NULL
) {
1472 printk(KERN_NOTICE CARDNAME
1473 ": Low memory, packet dropped.\n");
1474 lp
->stats
.rx_dropped
++;
1478 ! This should work without alignment, but it could be
1481 #ifndef SUPPORT_OLD_KERNEL
1482 /* TODO: Should I use 32bit alignment here ? */
1483 skb_reserve( skb
, 2 ); /* 16 bit alignment */
1487 #ifdef SUPPORT_OLD_KERNEL
1488 skb
->len
= packet_length
;
1491 data
= skb_put( skb
, packet_length
);
1494 /* QUESTION: Like in the TX routine, do I want
1495 to send the DWORDs or the bytes first, or some
1496 mixture. A mixture might improve already slow PIO
1498 PRINTK3((" Reading %d dwords (and %d bytes) \n",
1499 packet_length
>> 2, packet_length
& 3 ));
1500 insl(ioaddr
+ DATA_1
, data
, packet_length
>> 2 );
1501 /* read the left over bytes */
1502 insb( ioaddr
+ DATA_1
, data
+ (packet_length
& 0xFFFFFC),
1503 packet_length
& 0x3 );
1505 PRINTK3((" Reading %d words and %d byte(s) \n",
1506 (packet_length
>> 1 ), packet_length
& 1 );
1507 if ( packet_length
& 1 )
1508 *(data
++) = inb( ioaddr
+ DATA_1
);
1509 insw(ioaddr
+ DATA_1
, data
, (packet_length
+ 1 ) >> 1);
1510 if ( packet_length
& 1 ) {
1511 data
+= packet_length
& ~1;
1512 *((data
++) = inb( ioaddr
+ DATA_1
);
1516 print_packet( data
, packet_length
);
1519 #ifndef SUPPORT_OLD_KERNEL
1520 skb
->protocol
= eth_type_trans(skb
, dev
);
1523 lp
->stats
.rx_packets
++;
1526 lp
->stats
.rx_errors
++;
1528 if ( status
& RS_ALGNERR
) lp
->stats
.rx_frame_errors
++;
1529 if ( status
& (RS_TOOSHORT
| RS_TOOLONG
) )
1530 lp
->stats
.rx_length_errors
++;
1531 if ( status
& RS_BADCRC
) lp
->stats
.rx_crc_errors
++;
1533 /* error or good, tell the card to get rid of this packet */
1534 outw( MC_RELEASE
, ioaddr
+ MMU_CMD
);
1541 /*************************************************************************
1544 . Purpose: Handle a transmit error message. This will only be called
1545 . when an error, because of the AUTO_RELEASE mode.
1548 . Save pointer and packet no
1549 . Get the packet no from the top of the queue
1550 . check if it's valid ( if not, is this an error??? )
1551 . read the status word
1553 . ( resend? Not really, since we don't want old packets around )
1554 . Restore saved values
1555 ************************************************************************/
1556 static void smc_tx( struct net_device
* dev
)
1558 int ioaddr
= dev
->base_addr
;
1559 struct smc_local
*lp
= (struct smc_local
*)dev
->priv
;
1567 saved_packet
= inb( ioaddr
+ PNR_ARR
);
1568 packet_no
= inw( ioaddr
+ FIFO_PORTS
);
1571 /* select this as the packet to read from */
1572 outb( packet_no
, ioaddr
+ PNR_ARR
);
1574 /* read the first word from this packet */
1575 outw( PTR_AUTOINC
| PTR_READ
, ioaddr
+ POINTER
);
1577 tx_status
= inw( ioaddr
+ DATA_1
);
1578 PRINTK3((CARDNAME
": TX DONE STATUS: %4x \n", tx_status
));
1580 lp
->stats
.tx_errors
++;
1581 if ( tx_status
& TS_LOSTCAR
) lp
->stats
.tx_carrier_errors
++;
1582 if ( tx_status
& TS_LATCOL
) {
1583 printk(KERN_DEBUG CARDNAME
1584 ": Late collision occurred on last xmit.\n");
1585 lp
->stats
.tx_window_errors
++;
1588 if ( tx_status
& TS_16COL
) { ... }
1591 if ( tx_status
& TS_SUCCESS
) {
1592 printk(CARDNAME
": Successful packet caused interrupt \n");
1594 /* re-enable transmit */
1595 SMC_SELECT_BANK( 0 );
1596 outw( inw( ioaddr
+ TCR
) | TCR_ENABLE
, ioaddr
+ TCR
);
1598 /* kill the packet */
1599 SMC_SELECT_BANK( 2 );
1600 outw( MC_FREEPKT
, ioaddr
+ MMU_CMD
);
1602 /* one less packet waiting for me */
1603 lp
->packets_waiting
--;
1605 outb( saved_packet
, ioaddr
+ PNR_ARR
);
1609 /*----------------------------------------------------
1612 . this makes the board clean up everything that it can
1613 . and not talk to the outside world. Caused by
1614 . an 'ifconfig ethX down'
1616 -----------------------------------------------------*/
1617 static int smc_close(struct net_device
*dev
)
1622 /* clear everything */
1623 smc_shutdown( dev
->base_addr
);
1625 /* Update the statistics here. */
1633 /*------------------------------------------------------------
1634 . Get the current statistics.
1635 . This may be called with the card open or closed.
1636 .-------------------------------------------------------------*/
1637 static struct net_device_stats
* smc_query_statistics(struct net_device
*dev
) {
1638 struct smc_local
*lp
= (struct smc_local
*)dev
->priv
;
1643 /*-----------------------------------------------------------
1644 . smc_set_multicast_list
1646 . This routine will, depending on the values passed to it,
1647 . either make it accept multicast packets, go into
1648 . promiscuous mode ( for TCPDUMP and cousins ) or accept
1649 . a select set of multicast packets
1651 #ifdef SUPPORT_OLD_KERNEL
1652 static void smc_set_multicast_list( struct net_device
* dev
,
1653 int num_addrs
, void * addrs
)
1655 static void smc_set_multicast_list(struct net_device
*dev
)
1658 short ioaddr
= dev
->base_addr
;
1661 #ifdef SUPPORT_OLD_KERNEL
1662 if ( num_addrs
< 0 )
1664 if ( dev
->flags
& IFF_PROMISC
)
1666 outw( inw(ioaddr
+ RCR
) | RCR_PROMISC
, ioaddr
+ RCR
);
1668 /* BUG? I never disable promiscuous mode if multicasting was turned on.
1669 Now, I turn off promiscuous mode, but I don't do anything to multicasting
1670 when promiscuous mode is turned on.
1673 /* Here, I am setting this to accept all multicast packets.
1674 I don't need to zero the multicast table, because the flag is
1675 checked before the table is
1677 #ifdef SUPPORT_OLD_KERNEL
1678 else if ( num_addrs
> 20 ) /* arbitrary constant */
1680 else if (dev
->flags
& IFF_ALLMULTI
)
1682 outw( inw(ioaddr
+ RCR
) | RCR_ALMUL
, ioaddr
+ RCR
);
1684 /* We just get all multicast packets even if we only want them
1685 . from one source. This will be changed at some future
1687 #ifdef SUPPORT_OLD_KERNEL
1688 else if (num_addrs
> 0 ) {
1689 /* the old kernel support will not have hardware multicast support. It would
1690 involve more kludges, and make the multicast setting code even worse.
1691 Instead, just use the ALMUL method. This is reasonable, considering that
1694 outw( inw( ioaddr
+ RCR
) & ~RCR_PROMISC
, ioaddr
+ RCR
);
1695 outw( inw( ioadddr
+ RCR
) | RCR_ALMUL
, ioadddr
+ RCR
);
1698 else if (dev
->mc_count
) {
1699 /* support hardware multicasting */
1701 /* be sure I get rid of flags I might have set */
1702 outw( inw( ioaddr
+ RCR
) & ~(RCR_PROMISC
| RCR_ALMUL
),
1704 /* NOTE: this has to set the bank, so make sure it is the
1705 last thing called. The bank is set to zero at the top */
1706 smc_setmulticast( ioaddr
, dev
->mc_count
, dev
->mc_list
);
1710 outw( inw( ioaddr
+ RCR
) & ~(RCR_PROMISC
| RCR_ALMUL
),
1714 since I'm disabling all multicast entirely, I need to
1715 clear the multicast list
1717 SMC_SELECT_BANK( 3 );
1718 outw( 0, ioaddr
+ MULTICAST1
);
1719 outw( 0, ioaddr
+ MULTICAST2
);
1720 outw( 0, ioaddr
+ MULTICAST3
);
1721 outw( 0, ioaddr
+ MULTICAST4
);
1727 static char devicename
[9] = { 0, };
1728 static struct net_device devSMC9194
= {
1729 devicename
, /* device name is inserted by linux/drivers/net/net_init.c */
1731 0, 0, /* I/O address, IRQ */
1732 0, 0, 0, NULL
, smc_init
};
1738 MODULE_PARM(io
, "i");
1739 MODULE_PARM(irq
, "i");
1740 MODULE_PARM(ifport
, "i");
1742 int init_module(void)
1748 CARDNAME
": You shouldn't use auto-probing with insmod!\n" );
1750 /* copy the parameters from insmod into the device structure */
1751 devSMC9194
.base_addr
= io
;
1752 devSMC9194
.irq
= irq
;
1753 devSMC9194
.if_port
= ifport
;
1754 if ((result
= register_netdev(&devSMC9194
)) != 0)
1760 void cleanup_module(void)
1762 /* No need to check MOD_IN_USE, as sys_delete_module() checks. */
1763 unregister_netdev(&devSMC9194
);
1765 free_irq(devSMC9194
.irq
, &devSMC9194
);
1766 release_region(devSMC9194
.base_addr
, SMC_IO_EXTENT
);
1768 if (devSMC9194
.priv
)
1769 kfree_s(devSMC9194
.priv
, sizeof(struct smc_local
));