make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / drivers / net / atarilance.c
1 /* atarilance.c: Ethernet driver for VME Lance cards on the Atari */
2 /*
3         Written 1995/96 by Roman Hodek (Roman.Hodek@informatik.uni-erlangen.de)
4
5         This software may be used and distributed according to the terms
6         of the GNU General Public License, incorporated herein by reference.
7
8         This drivers was written with the following sources of reference:
9          - The driver for the Riebl Lance card by the TU Vienna.
10          - The modified TUW driver for PAM's VME cards
11          - The PC-Linux driver for Lance cards (but this is for bus master
12        cards, not the shared memory ones)
13          - The Amiga Ariadne driver
14
15         v1.0: (in 1.2.13pl4/0.9.13)
16               Initial version
17         v1.1: (in 1.2.13pl5)
18               more comments
19                   deleted some debugging stuff
20                   optimized register access (keep AREG pointing to CSR0)
21                   following AMD, CSR0_STRT should be set only after IDON is detected
22                   use memcpy() for data transfers, that also employs long word moves
23                   better probe procedure for 24-bit systems
24           non-VME-RieblCards need extra delays in memcpy
25                   must also do write test, since 0xfxe00000 may hit ROM
26                   use 8/32 tx/rx buffers, which should give better NFS performance;
27                     this is made possible by shifting the last packet buffer after the
28                     RieblCard reserved area
29     v1.2: (in 1.2.13pl8)
30               again fixed probing for the Falcon; 0xfe01000 hits phys. 0x00010000
31                   and thus RAM, in case of no Lance found all memory contents have to
32                   be restored!
33                   Now possible to compile as module.
34         v1.3: 03/30/96 Jes Sorensen, Roman (in 1.3)
35               Several little 1.3 adaptions
36                   When the lance is stopped it jumps back into little-endian
37                   mode. It is therefore necessary to put it back where it
38                   belongs, in big endian mode, in order to make things work.
39                   This might be the reason why multicast-mode didn't work
40                   before, but I'm not able to test it as I only got an Amiga
41                   (we had similar problems with the A2065 driver).
42
43 */
44
45 static char version[] = "atarilance.c: v1.3 04/04/96 "
46                                            "Roman.Hodek@informatik.uni-erlangen.de\n";
47
48 #include <linux/module.h>
49
50 #include <linux/stddef.h>
51 #include <linux/kernel.h>
52 #include <linux/sched.h>
53 #include <linux/string.h>
54 #include <linux/ptrace.h>
55 #include <linux/errno.h>
56 #include <linux/slab.h>
57 #include <linux/interrupt.h>
58 #include <linux/init.h>
59
60 #include <asm/setup.h>
61 #include <asm/irq.h>
62 #include <asm/atarihw.h>
63 #include <asm/atariints.h>
64 #include <asm/bitops.h>
65 #include <asm/io.h>
66
67 #include <linux/netdevice.h>
68 #include <linux/etherdevice.h>
69 #include <linux/skbuff.h>
70
71 /* Debug level:
72  *  0 = silent, print only serious errors
73  *  1 = normal, print error messages
74  *  2 = debug, print debug infos
75  *  3 = debug, print even more debug infos (packet data)
76  */
77
78 #define LANCE_DEBUG     1
79
80 #ifdef LANCE_DEBUG
81 static int lance_debug = LANCE_DEBUG;
82 #else
83 static int lance_debug = 1;
84 #endif
85 MODULE_PARM(lance_debug, "i");
86 MODULE_PARM_DESC(lance_debug, "atarilance debug level (0-3)");
87 MODULE_LICENSE("GPL");
88
89 /* Print debug messages on probing? */
90 #undef LANCE_DEBUG_PROBE
91
92 #define DPRINTK(n,a)                                                    \
93         do {                                                                            \
94                 if (lance_debug >= n)                                   \
95                         printk a;                                                       \
96         } while( 0 )
97
98 #ifdef LANCE_DEBUG_PROBE
99 # define PROBE_PRINT(a) printk a
100 #else
101 # define PROBE_PRINT(a)
102 #endif
103
104 /* These define the number of Rx and Tx buffers as log2. (Only powers
105  * of two are valid)
106  * Much more rx buffers (32) are reserved than tx buffers (8), since receiving
107  * is more time critical then sending and packets may have to remain in the
108  * board's memory when main memory is low.
109  */
110
111 #define TX_LOG_RING_SIZE                        3
112 #define RX_LOG_RING_SIZE                        5
113
114 /* These are the derived values */
115
116 #define TX_RING_SIZE                    (1 << TX_LOG_RING_SIZE)
117 #define TX_RING_LEN_BITS                (TX_LOG_RING_SIZE << 5)
118 #define TX_RING_MOD_MASK                (TX_RING_SIZE - 1)
119
120 #define RX_RING_SIZE                    (1 << RX_LOG_RING_SIZE)
121 #define RX_RING_LEN_BITS                (RX_LOG_RING_SIZE << 5)
122 #define RX_RING_MOD_MASK                (RX_RING_SIZE - 1)
123
124 #define TX_TIMEOUT      20
125
126 /* The LANCE Rx and Tx ring descriptors. */
127 struct lance_rx_head {
128         unsigned short                  base;           /* Low word of base addr */
129         volatile unsigned char  flag;
130         unsigned char                   base_hi;        /* High word of base addr (unused) */
131         short                                   buf_length;     /* This length is 2s complement! */
132         volatile short                  msg_length;     /* This length is "normal". */
133 };
134
135 struct lance_tx_head {
136         unsigned short                  base;           /* Low word of base addr */
137         volatile unsigned char  flag;
138         unsigned char                   base_hi;        /* High word of base addr (unused) */
139         short                                   length;         /* Length is 2s complement! */
140         volatile short                  misc;
141 };
142
143 struct ringdesc {
144         unsigned short  adr_lo;         /* Low 16 bits of address */
145         unsigned char   len;            /* Length bits */
146         unsigned char   adr_hi;         /* High 8 bits of address (unused) */
147 };
148
149 /* The LANCE initialization block, described in databook. */
150 struct lance_init_block {
151         unsigned short  mode;           /* Pre-set mode */
152         unsigned char   hwaddr[6];      /* Physical ethernet address */
153         unsigned                filter[2];      /* Multicast filter (unused). */
154         /* Receive and transmit ring base, along with length bits. */
155         struct ringdesc rx_ring;
156         struct ringdesc tx_ring;
157 };
158
159 /* The whole layout of the Lance shared memory */
160 struct lance_memory {
161         struct lance_init_block init;
162         struct lance_tx_head    tx_head[TX_RING_SIZE];
163         struct lance_rx_head    rx_head[RX_RING_SIZE];
164         char                                    packet_area[0]; /* packet data follow after the
165                                                                                          * init block and the ring
166                                                                                          * descriptors and are located
167                                                                                          * at runtime */
168 };
169
170 /* RieblCard specifics:
171  * The original TOS driver for these cards reserves the area from offset
172  * 0xee70 to 0xeebb for storing configuration data. Of interest to us is the
173  * Ethernet address there, and the magic for verifying the data's validity.
174  * The reserved area isn't touch by packet buffers. Furthermore, offset 0xfffe
175  * is reserved for the interrupt vector number.
176  */
177 #define RIEBL_RSVD_START        0xee70
178 #define RIEBL_RSVD_END          0xeec0
179 #define RIEBL_MAGIC                     0x09051990
180 #define RIEBL_MAGIC_ADDR        ((unsigned long *)(((char *)MEM) + 0xee8a))
181 #define RIEBL_HWADDR_ADDR       ((unsigned char *)(((char *)MEM) + 0xee8e))
182 #define RIEBL_IVEC_ADDR         ((unsigned short *)(((char *)MEM) + 0xfffe))
183
184 /* This is a default address for the old RieblCards without a battery
185  * that have no ethernet address at boot time. 00:00:36:04 is the
186  * prefix for Riebl cards, the 00:00 at the end is arbitrary.
187  */
188
189 static unsigned char OldRieblDefHwaddr[6] = {
190         0x00, 0x00, 0x36, 0x04, 0x00, 0x00
191 };
192
193
194 /* I/O registers of the Lance chip */
195
196 struct lance_ioreg {
197 /* base+0x0 */  volatile unsigned short data;
198 /* base+0x2 */  volatile unsigned short addr;
199                                 unsigned char                   _dummy1[3];
200 /* base+0x7 */  volatile unsigned char  ivec;
201                                 unsigned char                   _dummy2[5];
202 /* base+0xd */  volatile unsigned char  eeprom;
203                                 unsigned char                   _dummy3;
204 /* base+0xf */  volatile unsigned char  mem;
205 };
206
207 /* Types of boards this driver supports */
208
209 enum lance_type {
210         OLD_RIEBL,              /* old Riebl card without battery */
211         NEW_RIEBL,              /* new Riebl card with battery */
212         PAM_CARD                /* PAM card with EEPROM */
213 };
214
215 static char *lance_names[] = {
216         "Riebl-Card (without battery)",
217         "Riebl-Card (with battery)",
218         "PAM intern card"
219 };
220
221 /* The driver's private device structure */
222
223 struct lance_private {
224         enum lance_type         cardtype;
225         struct lance_ioreg      *iobase;
226         struct lance_memory     *mem;
227         int                     cur_rx, cur_tx; /* The next free ring entry */
228         int                     dirty_tx;               /* Ring entries to be freed. */
229                                 /* copy function */
230         void                    *(*memcpy_f)( void *, const void *, size_t );
231         struct net_device_stats stats;
232 /* This must be long for set_bit() */
233         long                    tx_full;
234         spinlock_t              devlock;
235 };
236
237 /* I/O register access macros */
238
239 #define MEM             lp->mem
240 #define DREG    IO->data
241 #define AREG    IO->addr
242 #define REGA(a) ( AREG = (a), DREG )
243
244 /* Definitions for packet buffer access: */
245 #define PKT_BUF_SZ              1544
246 /* Get the address of a packet buffer corresponding to a given buffer head */
247 #define PKTBUF_ADDR(head)       (((unsigned char *)(MEM)) + (head)->base)
248
249 /* Possible memory/IO addresses for probing */
250
251 struct lance_addr {
252         unsigned long   memaddr;
253         unsigned long   ioaddr;
254         int                             slow_flag;
255 } lance_addr_list[] = {
256         { 0xfe010000, 0xfe00fff0, 0 },  /* RieblCard VME in TT */
257         { 0xffc10000, 0xffc0fff0, 0 },  /* RieblCard VME in MegaSTE
258                                                                            (highest byte stripped) */
259         { 0xffe00000, 0xffff7000, 1 },  /* RieblCard in ST
260                                                                            (highest byte stripped) */
261         { 0xffd00000, 0xffff7000, 1 },  /* RieblCard in ST with hw modif. to
262                                                                            avoid conflict with ROM
263                                                                            (highest byte stripped) */
264         { 0xffcf0000, 0xffcffff0, 0 },  /* PAMCard VME in TT and MSTE
265                                                                            (highest byte stripped) */
266         { 0xfecf0000, 0xfecffff0, 0 },  /* Rhotron's PAMCard VME in TT and MSTE
267                                                                            (highest byte stripped) */
268 };
269
270 #define N_LANCE_ADDR    (sizeof(lance_addr_list)/sizeof(*lance_addr_list))
271
272
273 /* Definitions for the Lance */
274
275 /* tx_head flags */
276 #define TMD1_ENP                0x01    /* end of packet */
277 #define TMD1_STP                0x02    /* start of packet */
278 #define TMD1_DEF                0x04    /* deferred */
279 #define TMD1_ONE                0x08    /* one retry needed */
280 #define TMD1_MORE               0x10    /* more than one retry needed */
281 #define TMD1_ERR                0x40    /* error summary */
282 #define TMD1_OWN                0x80    /* ownership (set: chip owns) */
283
284 #define TMD1_OWN_CHIP   TMD1_OWN
285 #define TMD1_OWN_HOST   0
286
287 /* tx_head misc field */
288 #define TMD3_TDR                0x03FF  /* Time Domain Reflectometry counter */
289 #define TMD3_RTRY               0x0400  /* failed after 16 retries */
290 #define TMD3_LCAR               0x0800  /* carrier lost */
291 #define TMD3_LCOL               0x1000  /* late collision */
292 #define TMD3_UFLO               0x4000  /* underflow (late memory) */
293 #define TMD3_BUFF               0x8000  /* buffering error (no ENP) */
294
295 /* rx_head flags */
296 #define RMD1_ENP                0x01    /* end of packet */
297 #define RMD1_STP                0x02    /* start of packet */
298 #define RMD1_BUFF               0x04    /* buffer error */
299 #define RMD1_CRC                0x08    /* CRC error */
300 #define RMD1_OFLO               0x10    /* overflow */
301 #define RMD1_FRAM               0x20    /* framing error */
302 #define RMD1_ERR                0x40    /* error summary */
303 #define RMD1_OWN                0x80    /* ownership (set: ship owns) */
304
305 #define RMD1_OWN_CHIP   RMD1_OWN
306 #define RMD1_OWN_HOST   0
307
308 /* register names */
309 #define CSR0    0               /* mode/status */
310 #define CSR1    1               /* init block addr (low) */
311 #define CSR2    2               /* init block addr (high) */
312 #define CSR3    3               /* misc */
313 #define CSR8    8               /* address filter */
314 #define CSR15   15              /* promiscuous mode */
315
316 /* CSR0 */
317 /* (R=readable, W=writeable, S=set on write, C=clear on write) */
318 #define CSR0_INIT       0x0001          /* initialize (RS) */
319 #define CSR0_STRT       0x0002          /* start (RS) */
320 #define CSR0_STOP       0x0004          /* stop (RS) */
321 #define CSR0_TDMD       0x0008          /* transmit demand (RS) */
322 #define CSR0_TXON       0x0010          /* transmitter on (R) */
323 #define CSR0_RXON       0x0020          /* receiver on (R) */
324 #define CSR0_INEA       0x0040          /* interrupt enable (RW) */
325 #define CSR0_INTR       0x0080          /* interrupt active (R) */
326 #define CSR0_IDON       0x0100          /* initialization done (RC) */
327 #define CSR0_TINT       0x0200          /* transmitter interrupt (RC) */
328 #define CSR0_RINT       0x0400          /* receiver interrupt (RC) */
329 #define CSR0_MERR       0x0800          /* memory error (RC) */
330 #define CSR0_MISS       0x1000          /* missed frame (RC) */
331 #define CSR0_CERR       0x2000          /* carrier error (no heartbeat :-) (RC) */
332 #define CSR0_BABL       0x4000          /* babble: tx-ed too many bits (RC) */
333 #define CSR0_ERR        0x8000          /* error (RC) */
334
335 /* CSR3 */
336 #define CSR3_BCON       0x0001          /* byte control */
337 #define CSR3_ACON       0x0002          /* ALE control */
338 #define CSR3_BSWP       0x0004          /* byte swap (1=big endian) */
339
340
341
342 /***************************** Prototypes *****************************/
343
344 static int addr_accessible( volatile void *regp, int wordflag, int
345                             writeflag );
346 static unsigned long lance_probe1( struct net_device *dev, struct lance_addr
347                                    *init_rec );
348 static int lance_open( struct net_device *dev );
349 static void lance_init_ring( struct net_device *dev );
350 static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev );
351 static void lance_interrupt( int irq, void *dev_id, struct pt_regs *fp );
352 static int lance_rx( struct net_device *dev );
353 static int lance_close( struct net_device *dev );
354 static struct net_device_stats *lance_get_stats( struct net_device *dev );
355 static void set_multicast_list( struct net_device *dev );
356 static int lance_set_mac_address( struct net_device *dev, void *addr );
357 static void lance_tx_timeout (struct net_device *dev);
358
359 /************************* End of Prototypes **************************/
360
361
362
363 \f
364
365 static void *slow_memcpy( void *dst, const void *src, size_t len )
366
367 {       char *cto = dst;
368         const char *cfrom = src;
369
370         while( len-- ) {
371                 *cto++ = *cfrom++;
372                 MFPDELAY();
373         }
374         return( dst );
375 }
376
377
378 int __init atarilance_probe( struct net_device *dev )
379 {       
380         int i;
381         static int found;
382
383         SET_MODULE_OWNER(dev);
384
385         if (!MACH_IS_ATARI || found)
386                 /* Assume there's only one board possible... That seems true, since
387                  * the Riebl/PAM board's address cannot be changed. */
388                 return( ENODEV );
389
390         for( i = 0; i < N_LANCE_ADDR; ++i ) {
391                 if (lance_probe1( dev, &lance_addr_list[i] )) {
392                         found = 1;
393                         return( 0 );
394                 }
395         }
396
397         return( ENODEV );
398 }
399
400
401 /* Derived from hwreg_present() in atari/config.c: */
402
403 static int __init addr_accessible( volatile void *regp, int wordflag, int writeflag )
404 {
405         int             ret;
406         long    flags;
407         long    *vbr, save_berr;
408
409         save_flags(flags);
410         cli();
411
412         __asm__ __volatile__ ( "movec   %/vbr,%0" : "=r" (vbr) : );
413         save_berr = vbr[2];
414
415         __asm__ __volatile__
416         (       "movel  %/sp,%/d1\n\t"
417                 "movel  #Lberr,%2@\n\t"
418                 "moveq  #0,%0\n\t"
419                 "tstl   %3\n\t"
420                 "bne    1f\n\t"
421                 "moveb  %1@,%/d0\n\t"
422                 "nop    \n\t"
423                 "bra    2f\n"
424 "1:              movew  %1@,%/d0\n\t"
425                 "nop    \n"
426 "2:              tstl   %4\n\t"
427                 "beq    2f\n\t"
428                 "tstl   %3\n\t"
429                 "bne    1f\n\t"
430                 "clrb   %1@\n\t"
431                 "nop    \n\t"
432                 "moveb  %/d0,%1@\n\t"
433                 "nop    \n\t"
434                 "bra    2f\n"
435 "1:              clrw   %1@\n\t"
436                 "nop    \n\t"
437                 "movew  %/d0,%1@\n\t"
438                 "nop    \n"
439 "2:              moveq  #1,%0\n"
440 "Lberr:  movel  %/d1,%/sp"
441                 : "=&d" (ret)
442                 : "a" (regp), "a" (&vbr[2]), "rm" (wordflag), "rm" (writeflag)
443                 : "d0", "d1", "memory"
444         );
445
446         vbr[2] = save_berr;
447         restore_flags(flags);
448
449         return( ret );
450 }
451
452
453 static unsigned long __init lance_probe1( struct net_device *dev,
454                                            struct lance_addr *init_rec )
455 {
456         volatile unsigned short *memaddr =
457                 (volatile unsigned short *)init_rec->memaddr;
458         volatile unsigned short *ioaddr =
459                 (volatile unsigned short *)init_rec->ioaddr;
460         struct lance_private    *lp;
461         struct lance_ioreg              *IO;
462         int                                     i;
463         static int                              did_version;
464         unsigned short                  save1, save2;
465
466         PROBE_PRINT(( "Probing for Lance card at mem %#lx io %#lx\n",
467                                   (long)memaddr, (long)ioaddr ));
468
469         /* Test whether memory readable and writable */
470         PROBE_PRINT(( "lance_probe1: testing memory to be accessible\n" ));
471         if (!addr_accessible( memaddr, 1, 1 )) goto probe_fail;
472
473         /* Written values should come back... */
474         PROBE_PRINT(( "lance_probe1: testing memory to be writable (1)\n" ));
475         save1 = *memaddr;
476         *memaddr = 0x0001;
477         if (*memaddr != 0x0001) goto probe_fail;
478         PROBE_PRINT(( "lance_probe1: testing memory to be writable (2)\n" ));
479         *memaddr = 0x0000;
480         if (*memaddr != 0x0000) goto probe_fail;
481         *memaddr = save1;
482
483         /* First port should be readable and writable */
484         PROBE_PRINT(( "lance_probe1: testing ioport to be accessible\n" ));
485         if (!addr_accessible( ioaddr, 1, 1 )) goto probe_fail;
486
487         /* and written values should be readable */
488         PROBE_PRINT(( "lance_probe1: testing ioport to be writeable\n" ));
489         save2 = ioaddr[1];
490         ioaddr[1] = 0x0001;
491         if (ioaddr[1] != 0x0001) goto probe_fail;
492
493         /* The CSR0_INIT bit should not be readable */
494         PROBE_PRINT(( "lance_probe1: testing CSR0 register function (1)\n" ));
495         save1 = ioaddr[0];
496         ioaddr[1] = CSR0;
497         ioaddr[0] = CSR0_INIT | CSR0_STOP;
498         if (ioaddr[0] != CSR0_STOP) {
499                 ioaddr[0] = save1;
500                 ioaddr[1] = save2;
501                 goto probe_fail;
502         }
503         PROBE_PRINT(( "lance_probe1: testing CSR0 register function (2)\n" ));
504         ioaddr[0] = CSR0_STOP;
505         if (ioaddr[0] != CSR0_STOP) {
506                 ioaddr[0] = save1;
507                 ioaddr[1] = save2;
508                 goto probe_fail;
509         }
510
511         /* Now ok... */
512         PROBE_PRINT(( "lance_probe1: Lance card detected\n" ));
513         goto probe_ok;
514
515   probe_fail:
516         return( 0 );
517
518   probe_ok:
519         init_etherdev( dev, sizeof(struct lance_private) );
520         if (!dev->priv) {
521                 dev->priv = kmalloc( sizeof(struct lance_private), GFP_KERNEL );
522                 if (!dev->priv)
523                         return 0;
524         }
525         lp = (struct lance_private *)dev->priv;
526         MEM = (struct lance_memory *)memaddr;
527         IO = lp->iobase = (struct lance_ioreg *)ioaddr;
528         dev->base_addr = (unsigned long)ioaddr; /* informational only */
529         lp->memcpy_f = init_rec->slow_flag ? slow_memcpy : memcpy;
530
531         REGA( CSR0 ) = CSR0_STOP;
532
533         /* Now test for type: If the eeprom I/O port is readable, it is a
534          * PAM card */
535         if (addr_accessible( &(IO->eeprom), 0, 0 )) {
536                 /* Switch back to Ram */
537                 i = IO->mem;
538                 lp->cardtype = PAM_CARD;
539         }
540         else if (*RIEBL_MAGIC_ADDR == RIEBL_MAGIC) {
541                 lp->cardtype = NEW_RIEBL;
542         }
543         else
544                 lp->cardtype = OLD_RIEBL;
545
546         if (lp->cardtype == PAM_CARD ||
547                 memaddr == (unsigned short *)0xffe00000) {
548                 /* PAMs card and Riebl on ST use level 5 autovector */
549                 request_irq(IRQ_AUTO_5, lance_interrupt, IRQ_TYPE_PRIO,
550                             "PAM/Riebl-ST Ethernet", dev);
551                 dev->irq = (unsigned short)IRQ_AUTO_5;
552         }
553         else {
554                 /* For VME-RieblCards, request a free VME int;
555                  * (This must be unsigned long, since dev->irq is short and the
556                  * IRQ_MACHSPEC bit would be cut off...)
557                  */
558                 unsigned long irq = atari_register_vme_int();
559                 if (!irq) {
560                         printk( "Lance: request for VME interrupt failed\n" );
561                         return( 0 );
562                 }
563                 request_irq(irq, lance_interrupt, IRQ_TYPE_PRIO,
564                             "Riebl-VME Ethernet", dev);
565                 dev->irq = irq;
566         }
567
568         printk("%s: %s at io %#lx, mem %#lx, irq %d%s, hwaddr ",
569                    dev->name, lance_names[lp->cardtype],
570                    (unsigned long)ioaddr,
571                    (unsigned long)memaddr,
572                    dev->irq,
573                    init_rec->slow_flag ? " (slow memcpy)" : "" );
574
575         /* Get the ethernet address */
576         switch( lp->cardtype ) {
577           case OLD_RIEBL:
578                 /* No ethernet address! (Set some default address) */
579                 memcpy( dev->dev_addr, OldRieblDefHwaddr, 6 );
580                 break;
581           case NEW_RIEBL:
582                 lp->memcpy_f( dev->dev_addr, RIEBL_HWADDR_ADDR, 6 );
583                 break;
584           case PAM_CARD:
585                 i = IO->eeprom;
586                 for( i = 0; i < 6; ++i )
587                         dev->dev_addr[i] =
588                                 ((((unsigned short *)MEM)[i*2] & 0x0f) << 4) |
589                                 ((((unsigned short *)MEM)[i*2+1] & 0x0f));
590                 i = IO->mem;
591                 break;
592         }
593         for( i = 0; i < 6; ++i )
594                 printk( "%02x%s", dev->dev_addr[i], (i < 5) ? ":" : "\n" );
595         if (lp->cardtype == OLD_RIEBL) {
596                 printk( "%s: Warning: This is a default ethernet address!\n",
597                                 dev->name );
598                 printk( "      Use \"ifconfig hw ether ...\" to set the address.\n" );
599         }
600
601         lp->devlock = SPIN_LOCK_UNLOCKED;
602
603         MEM->init.mode = 0x0000;                /* Disable Rx and Tx. */
604         for( i = 0; i < 6; i++ )
605                 MEM->init.hwaddr[i] = dev->dev_addr[i^1]; /* <- 16 bit swap! */
606         MEM->init.filter[0] = 0x00000000;
607         MEM->init.filter[1] = 0x00000000;
608         MEM->init.rx_ring.adr_lo = offsetof( struct lance_memory, rx_head );
609         MEM->init.rx_ring.adr_hi = 0;
610         MEM->init.rx_ring.len    = RX_RING_LEN_BITS;
611         MEM->init.tx_ring.adr_lo = offsetof( struct lance_memory, tx_head );
612         MEM->init.tx_ring.adr_hi = 0;
613         MEM->init.tx_ring.len    = TX_RING_LEN_BITS;
614
615         if (lp->cardtype == PAM_CARD)
616                 IO->ivec = IRQ_SOURCE_TO_VECTOR(dev->irq);
617         else
618                 *RIEBL_IVEC_ADDR = IRQ_SOURCE_TO_VECTOR(dev->irq);
619
620         if (did_version++ == 0)
621                 DPRINTK( 1, ( version ));
622
623         /* The LANCE-specific entries in the device structure. */
624         dev->open = &lance_open;
625         dev->hard_start_xmit = &lance_start_xmit;
626         dev->stop = &lance_close;
627         dev->get_stats = &lance_get_stats;
628         dev->set_multicast_list = &set_multicast_list;
629         dev->set_mac_address = &lance_set_mac_address;
630
631         /* XXX MSch */
632         dev->tx_timeout = lance_tx_timeout;
633         dev->watchdog_timeo = TX_TIMEOUT;
634                         
635
636 #if 0
637         dev->start = 0;
638 #endif
639
640         memset( &lp->stats, 0, sizeof(lp->stats) );
641
642         return( 1 );
643 }
644
645 \f
646 static int lance_open( struct net_device *dev )
647
648 {       struct lance_private *lp = (struct lance_private *)dev->priv;
649         struct lance_ioreg       *IO = lp->iobase;
650         int i;
651
652         DPRINTK( 2, ( "%s: lance_open()\n", dev->name ));
653
654         lance_init_ring(dev);
655         /* Re-initialize the LANCE, and start it when done. */
656
657         REGA( CSR3 ) = CSR3_BSWP | (lp->cardtype == PAM_CARD ? CSR3_ACON : 0);
658         REGA( CSR2 ) = 0;
659         REGA( CSR1 ) = 0;
660         REGA( CSR0 ) = CSR0_INIT;
661         /* From now on, AREG is kept to point to CSR0 */
662
663         i = 1000000;
664         while (--i > 0)
665                 if (DREG & CSR0_IDON)
666                         break;
667         if (i < 0 || (DREG & CSR0_ERR)) {
668                 DPRINTK( 2, ( "lance_open(): opening %s failed, i=%d, csr0=%04x\n",
669                                           dev->name, i, DREG ));
670                 DREG = CSR0_STOP;
671                 return( -EIO );
672         }
673         DREG = CSR0_IDON;
674         DREG = CSR0_STRT;
675         DREG = CSR0_INEA;
676
677         netif_start_queue (dev);
678
679         DPRINTK( 2, ( "%s: LANCE is open, csr0 %04x\n", dev->name, DREG ));
680
681         return( 0 );
682 }
683
684
685 /* Initialize the LANCE Rx and Tx rings. */
686
687 static void lance_init_ring( struct net_device *dev )
688
689 {       struct lance_private *lp = (struct lance_private *)dev->priv;
690         int i;
691         unsigned offset;
692
693         lp->tx_full = 0;
694         lp->cur_rx = lp->cur_tx = 0;
695         lp->dirty_tx = 0;
696
697         offset = offsetof( struct lance_memory, packet_area );
698
699 /* If the packet buffer at offset 'o' would conflict with the reserved area
700  * of RieblCards, advance it */
701 #define CHECK_OFFSET(o)                                                                                                          \
702         do {                                                                                                                                     \
703                 if (lp->cardtype == OLD_RIEBL || lp->cardtype == NEW_RIEBL) {            \
704                         if (((o) < RIEBL_RSVD_START) ? (o)+PKT_BUF_SZ > RIEBL_RSVD_START \
705                                                                                  : (o) < RIEBL_RSVD_END)                         \
706                                 (o) = RIEBL_RSVD_END;                                                                            \
707                 }                                                                                                                                        \
708         } while(0)
709
710         for( i = 0; i < TX_RING_SIZE; i++ ) {
711                 CHECK_OFFSET(offset);
712                 MEM->tx_head[i].base = offset;
713                 MEM->tx_head[i].flag = TMD1_OWN_HOST;
714                 MEM->tx_head[i].base_hi = 0;
715                 MEM->tx_head[i].length = 0;
716                 MEM->tx_head[i].misc = 0;
717                 offset += PKT_BUF_SZ;
718         }
719
720         for( i = 0; i < RX_RING_SIZE; i++ ) {
721                 CHECK_OFFSET(offset);
722                 MEM->rx_head[i].base = offset;
723                 MEM->rx_head[i].flag = TMD1_OWN_CHIP;
724                 MEM->rx_head[i].base_hi = 0;
725                 MEM->rx_head[i].buf_length = -PKT_BUF_SZ;
726                 MEM->rx_head[i].msg_length = 0;
727                 offset += PKT_BUF_SZ;
728         }
729 }
730
731
732 /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
733
734
735 static void lance_tx_timeout (struct net_device *dev)
736 {
737         struct lance_private *lp = (struct lance_private *) dev->priv;
738         struct lance_ioreg       *IO = lp->iobase;
739         
740         AREG = CSR0;
741         DPRINTK( 1, ( "%s: transmit timed out, status %04x, resetting.\n",
742                           dev->name, DREG ));
743         DREG = CSR0_STOP;
744         /*
745          * Always set BSWP after a STOP as STOP puts it back into
746          * little endian mode.
747          */
748         REGA( CSR3 ) = CSR3_BSWP | (lp->cardtype == PAM_CARD ? CSR3_ACON : 0);
749         lp->stats.tx_errors++;
750 #ifndef final_version
751                 {       int i;
752                         DPRINTK( 2, ( "Ring data: dirty_tx %d cur_tx %d%s cur_rx %d\n",
753                                                   lp->dirty_tx, lp->cur_tx,
754                                                   lp->tx_full ? " (full)" : "",
755                                                   lp->cur_rx ));
756                         for( i = 0 ; i < RX_RING_SIZE; i++ )
757                                 DPRINTK( 2, ( "rx #%d: base=%04x blen=%04x mlen=%04x\n",
758                                                           i, MEM->rx_head[i].base,
759                                                           -MEM->rx_head[i].buf_length,
760                                                           MEM->rx_head[i].msg_length ));
761                         for( i = 0 ; i < TX_RING_SIZE; i++ )
762                                 DPRINTK( 2, ( "tx #%d: base=%04x len=%04x misc=%04x\n",
763                                                           i, MEM->tx_head[i].base,
764                                                           -MEM->tx_head[i].length,
765                                                           MEM->tx_head[i].misc ));
766                 }
767 #endif   
768         /* XXX MSch: maybe purge/reinit ring here */
769         /* lance_restart, essentially */
770         lance_init_ring(dev);
771         REGA( CSR0 ) = CSR0_INEA | CSR0_INIT | CSR0_STRT;
772         dev->trans_start = jiffies;
773         netif_wake_queue (dev);
774 }
775
776 /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
777
778 static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
779
780 {       struct lance_private *lp = (struct lance_private *)dev->priv;
781         struct lance_ioreg       *IO = lp->iobase;
782         int entry, len;
783         struct lance_tx_head *head;
784         unsigned long flags;
785
786         DPRINTK( 2, ( "%s: lance_start_xmit() called, csr0 %4.4x.\n",
787                                   dev->name, DREG ));
788
789         netif_stop_queue (dev);
790
791         /* Fill in a Tx ring entry */
792         if (lance_debug >= 3) {
793                 u_char *p;
794                 int i;
795                 printk( "%s: TX pkt type 0x%04x from ", dev->name,
796                                 ((u_short *)skb->data)[6]);
797                 for( p = &((u_char *)skb->data)[6], i = 0; i < 6; i++ )
798                         printk("%02x%s", *p++, i != 5 ? ":" : "" );
799                 printk(" to ");
800                 for( p = (u_char *)skb->data, i = 0; i < 6; i++ )
801                         printk("%02x%s", *p++, i != 5 ? ":" : "" );
802                 printk(" data at 0x%08x len %d\n", (int)skb->data,
803                            (int)skb->len );
804         }
805
806         /* We're not prepared for the int until the last flags are set/reset. And
807          * the int may happen already after setting the OWN_CHIP... */
808         spin_lock_irqsave (&lp->devlock, flags);
809
810         /* Mask to ring buffer boundary. */
811         entry = lp->cur_tx & TX_RING_MOD_MASK;
812         head  = &(MEM->tx_head[entry]);
813
814         /* Caution: the write order is important here, set the "ownership" bits
815          * last.
816          */
817
818         /* The old LANCE chips doesn't automatically pad buffers to min. size. */
819         len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
820         /* PAM-Card has a bug: Can only send packets with even number of bytes! */
821         if (lp->cardtype == PAM_CARD && (len & 1))
822                 ++len;
823
824         head->length = -len;
825         head->misc = 0;
826         lp->memcpy_f( PKTBUF_ADDR(head), (void *)skb->data, skb->len );
827         head->flag = TMD1_OWN_CHIP | TMD1_ENP | TMD1_STP;
828         lp->stats.tx_bytes += skb->len;
829         dev_kfree_skb( skb );
830         lp->cur_tx++;
831         while( lp->cur_tx >= TX_RING_SIZE && lp->dirty_tx >= TX_RING_SIZE ) {
832                 lp->cur_tx -= TX_RING_SIZE;
833                 lp->dirty_tx -= TX_RING_SIZE;
834         }
835
836         /* Trigger an immediate send poll. */
837         DREG = CSR0_INEA | CSR0_TDMD;
838         dev->trans_start = jiffies;
839
840         if ((MEM->tx_head[(entry+1) & TX_RING_MOD_MASK].flag & TMD1_OWN) ==
841                 TMD1_OWN_HOST)
842                 netif_start_queue (dev);
843         else
844                 lp->tx_full = 1;
845         spin_unlock_irqrestore (&lp->devlock, flags);
846
847         return 0;
848 }
849
850 /* The LANCE interrupt handler. */
851
852 static void lance_interrupt( int irq, void *dev_id, struct pt_regs *fp)
853 {
854         struct net_device *dev = dev_id;
855         struct lance_private *lp;
856         struct lance_ioreg       *IO;
857         int csr0, boguscnt = 10;
858
859         if (dev == NULL) {
860                 DPRINTK( 1, ( "lance_interrupt(): interrupt for unknown device.\n" ));
861                 return;
862         }
863
864         lp = (struct lance_private *)dev->priv;
865         IO = lp->iobase;
866         spin_lock (&lp->devlock);
867
868         AREG = CSR0;
869
870         while( ((csr0 = DREG) & (CSR0_ERR | CSR0_TINT | CSR0_RINT)) &&
871                    --boguscnt >= 0) {
872                 /* Acknowledge all of the current interrupt sources ASAP. */
873                 DREG = csr0 & ~(CSR0_INIT | CSR0_STRT | CSR0_STOP |
874                                                                         CSR0_TDMD | CSR0_INEA);
875
876                 DPRINTK( 2, ( "%s: interrupt  csr0=%04x new csr=%04x.\n",
877                                           dev->name, csr0, DREG ));
878
879                 if (csr0 & CSR0_RINT)                   /* Rx interrupt */
880                         lance_rx( dev );
881
882                 if (csr0 & CSR0_TINT) {                 /* Tx-done interrupt */
883                         int dirty_tx = lp->dirty_tx;
884
885                         while( dirty_tx < lp->cur_tx) {
886                                 int entry = dirty_tx & TX_RING_MOD_MASK;
887                                 int status = MEM->tx_head[entry].flag;
888
889                                 if (status & TMD1_OWN_CHIP)
890                                         break;                  /* It still hasn't been Txed */
891
892                                 MEM->tx_head[entry].flag = 0;
893
894                                 if (status & TMD1_ERR) {
895                                         /* There was an major error, log it. */
896                                         int err_status = MEM->tx_head[entry].misc;
897                                         lp->stats.tx_errors++;
898                                         if (err_status & TMD3_RTRY) lp->stats.tx_aborted_errors++;
899                                         if (err_status & TMD3_LCAR) lp->stats.tx_carrier_errors++;
900                                         if (err_status & TMD3_LCOL) lp->stats.tx_window_errors++;
901                                         if (err_status & TMD3_UFLO) {
902                                                 /* Ackk!  On FIFO errors the Tx unit is turned off! */
903                                                 lp->stats.tx_fifo_errors++;
904                                                 /* Remove this verbosity later! */
905                                                 DPRINTK( 1, ( "%s: Tx FIFO error! Status %04x\n",
906                                                                           dev->name, csr0 ));
907                                                 /* Restart the chip. */
908                                                 DREG = CSR0_STRT;
909                                         }
910                                 } else {
911                                         if (status & (TMD1_MORE | TMD1_ONE | TMD1_DEF))
912                                                 lp->stats.collisions++;
913                                         lp->stats.tx_packets++;
914                                 }
915
916                                 /* XXX MSch: free skb?? */
917                                 dirty_tx++;
918                         }
919
920 #ifndef final_version
921                         if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) {
922                                 DPRINTK( 0, ( "out-of-sync dirty pointer,"
923                                                           " %d vs. %d, full=%ld.\n",
924                                                           dirty_tx, lp->cur_tx, lp->tx_full ));
925                                 dirty_tx += TX_RING_SIZE;
926                         }
927 #endif
928
929                         if (lp->tx_full && (netif_queue_stopped(dev))
930                                 && dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
931                                 /* The ring is no longer full, clear tbusy. */
932                                 lp->tx_full = 0;
933                                 netif_wake_queue (dev);
934                         }
935
936                         lp->dirty_tx = dirty_tx;
937                 }
938
939                 /* Log misc errors. */
940                 if (csr0 & CSR0_BABL) lp->stats.tx_errors++; /* Tx babble. */
941                 if (csr0 & CSR0_MISS) lp->stats.rx_errors++; /* Missed a Rx frame. */
942                 if (csr0 & CSR0_MERR) {
943                         DPRINTK( 1, ( "%s: Bus master arbitration failure (?!?), "
944                                                   "status %04x.\n", dev->name, csr0 ));
945                         /* Restart the chip. */
946                         DREG = CSR0_STRT;
947                 }
948         }
949
950     /* Clear any other interrupt, and set interrupt enable. */
951         DREG = CSR0_BABL | CSR0_CERR | CSR0_MISS | CSR0_MERR |
952                    CSR0_IDON | CSR0_INEA;
953
954         DPRINTK( 2, ( "%s: exiting interrupt, csr0=%#04x.\n",
955                                   dev->name, DREG ));
956
957         spin_unlock (&lp->devlock);
958 }
959
960
961 static int lance_rx( struct net_device *dev )
962
963 {       struct lance_private *lp = (struct lance_private *)dev->priv;
964         int entry = lp->cur_rx & RX_RING_MOD_MASK;
965         int i;
966
967         DPRINTK( 2, ( "%s: rx int, flag=%04x\n", dev->name,
968                                   MEM->rx_head[entry].flag ));
969
970         /* If we own the next entry, it's a new packet. Send it up. */
971         while( (MEM->rx_head[entry].flag & RMD1_OWN) == RMD1_OWN_HOST ) {
972                 struct lance_rx_head *head = &(MEM->rx_head[entry]);
973                 int status = head->flag;
974
975                 if (status != (RMD1_ENP|RMD1_STP)) {            /* There was an error. */
976                         /* There is a tricky error noted by John Murphy,
977                            <murf@perftech.com> to Russ Nelson: Even with full-sized
978                            buffers it's possible for a jabber packet to use two
979                            buffers, with only the last correctly noting the error. */
980                         if (status & RMD1_ENP)  /* Only count a general error at the */
981                                 lp->stats.rx_errors++; /* end of a packet.*/
982                         if (status & RMD1_FRAM) lp->stats.rx_frame_errors++;
983                         if (status & RMD1_OFLO) lp->stats.rx_over_errors++;
984                         if (status & RMD1_CRC) lp->stats.rx_crc_errors++;
985                         if (status & RMD1_BUFF) lp->stats.rx_fifo_errors++;
986                         head->flag &= (RMD1_ENP|RMD1_STP);
987                 } else {
988                         /* Malloc up new buffer, compatible with net-3. */
989                         short pkt_len = head->msg_length & 0xfff;
990                         struct sk_buff *skb;
991
992                         if (pkt_len < 60) {
993                                 printk( "%s: Runt packet!\n", dev->name );
994                                 lp->stats.rx_errors++;
995                         }
996                         else {
997                                 skb = dev_alloc_skb( pkt_len+2 );
998                                 if (skb == NULL) {
999                                         DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n",
1000                                                                   dev->name ));
1001                                         for( i = 0; i < RX_RING_SIZE; i++ )
1002                                                 if (MEM->rx_head[(entry+i) & RX_RING_MOD_MASK].flag &
1003                                                         RMD1_OWN_CHIP)
1004                                                         break;
1005
1006                                         if (i > RX_RING_SIZE - 2) {
1007                                                 lp->stats.rx_dropped++;
1008                                                 head->flag |= RMD1_OWN_CHIP;
1009                                                 lp->cur_rx++;
1010                                         }
1011                                         break;
1012                                 }
1013
1014                                 if (lance_debug >= 3) {
1015                                         u_char *data = PKTBUF_ADDR(head), *p;
1016                                         printk( "%s: RX pkt type 0x%04x from ", dev->name,
1017                                                         ((u_short *)data)[6]);
1018                                         for( p = &data[6], i = 0; i < 6; i++ )
1019                                                 printk("%02x%s", *p++, i != 5 ? ":" : "" );
1020                                         printk(" to ");
1021                                         for( p = data, i = 0; i < 6; i++ )
1022                                                 printk("%02x%s", *p++, i != 5 ? ":" : "" );
1023                                         printk(" data %02x %02x %02x %02x %02x %02x %02x %02x "
1024                                                    "len %d\n",
1025                                                    data[15], data[16], data[17], data[18],
1026                                                    data[19], data[20], data[21], data[22],
1027                                                    pkt_len );
1028                                 }
1029
1030                                 skb->dev = dev;
1031                                 skb_reserve( skb, 2 );  /* 16 byte align */
1032                                 skb_put( skb, pkt_len );        /* Make room */
1033                                 lp->memcpy_f( skb->data, PKTBUF_ADDR(head), pkt_len );
1034                                 skb->protocol = eth_type_trans( skb, dev );
1035                                 netif_rx( skb );
1036                                 dev->last_rx = jiffies;
1037                                 lp->stats.rx_packets++;
1038                                 lp->stats.rx_bytes += pkt_len;
1039                         }
1040                 }
1041
1042                 head->flag |= RMD1_OWN_CHIP;
1043                 entry = (++lp->cur_rx) & RX_RING_MOD_MASK;
1044         }
1045         lp->cur_rx &= RX_RING_MOD_MASK;
1046
1047         /* From lance.c (Donald Becker): */
1048         /* We should check that at least two ring entries are free.      If not,
1049            we should free one and mark stats->rx_dropped++. */
1050
1051         return 0;
1052 }
1053
1054
1055 static int lance_close( struct net_device *dev )
1056
1057 {       struct lance_private *lp = (struct lance_private *)dev->priv;
1058         struct lance_ioreg       *IO = lp->iobase;
1059
1060         netif_stop_queue (dev);
1061
1062         AREG = CSR0;
1063
1064         DPRINTK( 2, ( "%s: Shutting down ethercard, status was %2.2x.\n",
1065                                   dev->name, DREG ));
1066
1067         /* We stop the LANCE here -- it occasionally polls
1068            memory if we don't. */
1069         DREG = CSR0_STOP;
1070
1071         return 0;
1072 }
1073
1074
1075 static struct net_device_stats *lance_get_stats( struct net_device *dev )
1076
1077 {       struct lance_private *lp = (struct lance_private *)dev->priv;
1078
1079         return &lp->stats;
1080 }
1081
1082
1083 /* Set or clear the multicast filter for this adaptor.
1084    num_addrs == -1              Promiscuous mode, receive all packets
1085    num_addrs == 0               Normal mode, clear multicast list
1086    num_addrs > 0                Multicast mode, receive normal and MC packets, and do
1087                                                 best-effort filtering.
1088  */
1089
1090 static void set_multicast_list( struct net_device *dev )
1091
1092 {       struct lance_private *lp = (struct lance_private *)dev->priv;
1093         struct lance_ioreg       *IO = lp->iobase;
1094
1095         if (netif_running(dev))
1096                 /* Only possible if board is already started */
1097                 return;
1098
1099         /* We take the simple way out and always enable promiscuous mode. */
1100         DREG = CSR0_STOP; /* Temporarily stop the lance. */
1101
1102         if (dev->flags & IFF_PROMISC) {
1103                 /* Log any net taps. */
1104                 DPRINTK( 1, ( "%s: Promiscuous mode enabled.\n", dev->name ));
1105                 REGA( CSR15 ) = 0x8000; /* Set promiscuous mode */
1106         } else {
1107                 short multicast_table[4];
1108                 int num_addrs = dev->mc_count;
1109                 int i;
1110                 /* We don't use the multicast table, but rely on upper-layer
1111                  * filtering. */
1112                 memset( multicast_table, (num_addrs == 0) ? 0 : -1,
1113                                 sizeof(multicast_table) );
1114                 for( i = 0; i < 4; i++ )
1115                         REGA( CSR8+i ) = multicast_table[i];
1116                 REGA( CSR15 ) = 0; /* Unset promiscuous mode */
1117         }
1118
1119         /*
1120          * Always set BSWP after a STOP as STOP puts it back into
1121          * little endian mode.
1122          */
1123         REGA( CSR3 ) = CSR3_BSWP | (lp->cardtype == PAM_CARD ? CSR3_ACON : 0);
1124
1125         /* Resume normal operation and reset AREG to CSR0 */
1126         REGA( CSR0 ) = CSR0_IDON | CSR0_INEA | CSR0_STRT;
1127 }
1128
1129
1130 /* This is needed for old RieblCards and possible for new RieblCards */
1131
1132 static int lance_set_mac_address( struct net_device *dev, void *addr )
1133
1134 {       struct lance_private *lp = (struct lance_private *)dev->priv;
1135         struct sockaddr *saddr = addr;
1136         int i;
1137
1138         if (lp->cardtype != OLD_RIEBL && lp->cardtype != NEW_RIEBL)
1139                 return( -EOPNOTSUPP );
1140
1141         if (netif_running(dev)) {
1142                 /* Only possible while card isn't started */
1143                 DPRINTK( 1, ( "%s: hwaddr can be set only while card isn't open.\n",
1144                                           dev->name ));
1145                 return( -EIO );
1146         }
1147
1148         memcpy( dev->dev_addr, saddr->sa_data, dev->addr_len );
1149         for( i = 0; i < 6; i++ )
1150                 MEM->init.hwaddr[i] = dev->dev_addr[i^1]; /* <- 16 bit swap! */
1151         lp->memcpy_f( RIEBL_HWADDR_ADDR, dev->dev_addr, 6 );
1152         /* set also the magic for future sessions */
1153         *RIEBL_MAGIC_ADDR = RIEBL_MAGIC;
1154
1155         return( 0 );
1156 }
1157
1158 \f
1159 #ifdef MODULE
1160 static struct net_device atarilance_dev;
1161
1162 int init_module(void)
1163
1164 {       int err;
1165
1166         atarilance_dev.init = atarilance_probe;
1167         if ((err = register_netdev( &atarilance_dev ))) {
1168                 if (err == -EIO)  {
1169                         printk( "No Atari Lance board found. Module not loaded.\n");
1170                 }
1171                 return( err );
1172         }
1173         return( 0 );
1174 }
1175
1176 void cleanup_module(void)
1177
1178 {
1179         unregister_netdev( &atarilance_dev );
1180 }
1181
1182 #endif /* MODULE */
1183 \f
1184
1185 /*
1186  * Local variables:
1187  *  c-indent-level: 4
1188  *  tab-width: 4
1189  * End:
1190  */