This source file includes following definitions.
- tio_sia_write
- card_type
- read_eeprom
- generic21040_error
- generic21041_error
- generic21040_select
- generic21041_select
- auto21140_select
- generic21140_select
- tulip_open
- tulip_init_ring
- tulip_start_xmit
- tulip_interrupt
- tulip_rx
- tulip_close
- tulip_get_stats
- set_multicast_list
- set_mac_address
- tulip_alloc
- tulip_hwinit
- tulip_probe
- init_module
- cleanup_module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 static char *version =
18 "tulip.c:v0.10 8/11/95 becker@cesdis.gsfc.nasa.gov\n"
19 " +0.68 3/09/96 "
20 "http://www.dsl.tutics.tut.ac.jp/~manabe/linux/tulip.html\n";
21
22
23
24
25 #define TULIP_10TP_PORT 0
26 #define TULIP_100TP_PORT 1
27 #define TULIP_AUI_PORT 1
28 #define TULIP_BNC_PORT 2
29
30 #ifndef TULIP_PORT
31 #define TULIP_PORT TULIP_10TP_PORT
32 #endif
33
34
35
36
37
38
39
40 #include <linux/config.h>
41
42 #if defined(MODULE) && defined(CONFIG_MODVERSIONS)
43 #define MODVERSIONS
44 #include <linux/modversions.h>
45 #endif
46
47 #include <linux/version.h>
48
49 #if LINUX_VERSION_CODE < 0x10300
50
51 #define virt_to_bus(address) (unsigned long)(address)
52 #define bus_to_virt(address) (void *)(address)
53 #define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
54 #ifdef MODULE
55 #include <linux/module.h>
56 char kernel_version[] = UTS_RELEASE;
57 #else
58 #undef MOD_INC_USE_COUNT
59 #undef MOD_DEC_USE_COUNT
60 #define MOD_INC_USE_COUNT
61 #define MOD_DEC_USE_COUNT
62 #endif
63 #else
64
65 #include <linux/module.h>
66 #endif
67
68 #include <linux/kernel.h>
69 #include <linux/sched.h>
70 #include <linux/string.h>
71 #include <linux/ptrace.h>
72 #include <linux/errno.h>
73 #include <linux/ioport.h>
74 #include <linux/malloc.h>
75 #include <linux/interrupt.h>
76 #include <linux/pci.h>
77 #include <linux/bios32.h>
78 #include <asm/byteorder.h>
79 #include <asm/bitops.h>
80 #include <asm/io.h>
81 #include <asm/dma.h>
82
83 #include <linux/netdevice.h>
84 #include <linux/etherdevice.h>
85 #include <linux/skbuff.h>
86
87
88
89 #define TULIP_TOTAL_SIZE 0x80
90
91 #ifdef TULIP_DEBUG
92 int tulip_debug = TULIP_DEBUG;
93 #else
94 int tulip_debug = 3;
95 #endif
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 #define TX_RING_SIZE 4
158 #define RX_RING_SIZE 4
159 #define PKT_BUF_SZ 1536
160
161
162
163
164
165 #define FULL_DUPLEX_MAGIC 0x6969
166
167
168
169 #define PCI_DEVICE_ID_NONE 0xFFFF
170 #define ETHNAMSIZ 8
171 #define ROUND_UP(size, n) ((size + n - 1) & ~(n - 1))
172
173
174
175 enum tulip_offsets {
176
177 CSR0=0,
178 CSR1=0x08,
179 CSR2=0x10,
180 CSR3=0x18,
181 CSR4=0x20,
182 CSR5=0x28,
183 CSR6=0x30,
184 CSR7=0x38,
185 CSR8=0x40,
186 CSR9=0x48,
187 CSR10=0x50,
188 CSR11=0x58,
189 CSR12=0x60,
190 CSR13=0x68,
191 CSR14=0x70,
192 CSR15=0x78
193 };
194
195
196 #define TBMOD_RESERVED 0xfff80000
197 #define TBMOD_RESET 0x00000001
198 #define TBMOD_BIGENDIAN 0x00000080
199
200
201
202
203
204
205
206 #define TBMOD_ALIGN0 0x00000000
207 #define TBMOD_ALIGN8 0x00004000
208 #define TBMOD_ALIGN16 0x00008000
209 #define TBMOD_ALIGN32 (TBMOD_ALIGN8|TBMOD_ALIGN16)
210 #define TBMOD_BURST0 0x00000000
211 #define TBMOD_BURST1 0x00000100
212 #define TBMOD_BURST2 0x00000200
213 #define TBMOD_BURST4 0x00000400
214 #define TBMOD_BURST8 0x00000800
215 #define TBMOD_BURST16 0x00001000
216 #define TBMOD_BURST32 0x00002000
217
218
219
220 #define TPOLL_START 0x00000001
221 #define TPOLL_TRIGGER 0x00000000
222
223
224 #define TSTAT_BUSERROR 0x03800000
225 #define TSTAT_SYSERROR 0x00002000
226 #define TSTAT_TxSTAT 0x00700000
227 #define TSTAT_RxSTAT 0x000e0000
228 #define TSTAT_LKFAIL 0x00001000
229 #define TSTAT_NORINTR 0x00010000
230 #define TSTAT_ABNINTR 0x00008000
231 #define TSTAT_RxMISSED 0x00000100
232 #define TSTAT_RxUNABL 0x00000080
233 #define TSTAT_RxINTR 0x00000040
234 #define TSTAT_LKPASS 0x00000010
235 #define TSTAT_TEXPIRED 0x00000800
236 #define TSTAT_TxTOUT 0x00000008
237 #define TSTAT_TxUNABL 0x00000004
238 #define TSTAT_TxINTR 0x00000001
239 #define TSTAT_CLEARINTR 0x0001ffff
240
241
242 #define TCMOD_SCRM 0x01000000
243 #define TCMOD_PCS 0x00800000
244 #define TCMOD_TxTHMODE 0x00400000
245 #define TCMOD_SW100TP 0x00040000
246 #define TCMOD_CAPTURE 0x00020000
247 #define TCMOD_FULLDUPLEX 0x00000200
248 #define TCMOD_TH128 0x00008000
249 #define TCMOD_TxSTART 0x00002000
250 #define TCMOD_RxSTART 0x00000002
251 #define TCMOD_ALLMCAST 0x00000080
252 #define TCMOD_PROMISC 0x00000040
253 #define TCMOD_BOFFCOUNTER 0x00000020
254 #define TCMOD_INVFILTER 0x00000010
255 #define TCMOD_HONLYFILTER 0x00000004
256 #define TCMOD_HPFILTER 0x00000001
257 #define TCMOD_MODEMASK (TCMOD_ALLMCAST|TCMOD_PROMISC)
258 #define TCMOD_FILTERMASK (TCMOD_HONLYFILTER|TCMOD_HPFILTER|TCMOD_INVFILTER)
259 #define TCMOD_TRxSTART (TCMOD_TxSTART|TCMOD_RxSTART)
260 #define TCMOD_BASE (TCMOD_CAPTURE|TCMOD_BOFFCOUNTER)
261 #define TCMOD_10TP (TCMOD_TxTHMODE|TCMOD_BASE)
262 #define TCMOD_100TP (TCMOD_SCRM|TCMOD_PCS|TCMOD_SW100TP|TCMOD_BASE)
263 #define TCMOD_AUTO (TCMOD_SW100TP|TCMOD_TH128|TCMOD_10TP)
264
265
266 #define TINTR_ENABLE 0xFFFFFFFF
267 #define TINTR_DISABLE 0x00000000
268
269
270 #define TSIAS_CONERROR 0x00000002
271 #define TSIAS_LNKERROR 0x00000004
272 #define TGEPR_LK10NG 0x00000080
273 #define TGEPR_LK100NG 0x00000040
274 #define TGEPR_DETECT 0x00000020
275 #define TGEPR_HALFDUPLEX 0x00000008
276 #define TGEPR_PHYLOOPBACK 0x00000004
277 #define TGEPR_FORCEALED 0x00000002
278 #define TGEPR_FORCE100 0x00000001
279
280
281 #define TSIAC_OUTEN 0x0000e000
282 #define TSIAC_SELED 0x00000f00
283 #define TSIAC_INEN 0x00001000
284 #define TSIAC_NO10TP 0x00000008
285 #define TSIAC_CONFIG 0x00000004
286 #define TSIAC_SWRESET 0x00000001
287 #define TSIAC_RESET 0x00000000
288 #define TSIAC_C21041 (TSIAC_OUTEN|TSIAC_SELED|TSIAC_SWRESET)
289 #define TSIAC_C21040 TSIAC_CONFIG
290
291
292 #define TSIAX_NO10TP 0x0000f73d
293 #define TSIAX_10TP 0x0000ff3f
294
295
296 #define TSIAG_SWBNCAUI 0x00000008
297 #define TSIAG_BNC 0x00000006
298 #define TSIAG_AUI (TSIAG_BNC|TSIAG_SWBNCAUI)
299 #define TSIAG_10TP 0x00000000
300
301
302 #define TRING_OWN 0x80000000
303 #define TRING_CLEAR 0x00000000
304 #define TRING_ERROR 0x00008000
305 #define TRING_ETxTO 0x00004000
306 #define TRING_ELCOLL 0x00000200
307 #define TRING_EFCOLL 0x00000100
308 #define TRING_ELCARR 0x00000800
309 #define TRING_ENCARR 0x00000400
310 #define TRING_ENOHB 0x00000080
311 #define TRING_ELINK 0x00000004
312 #define TRING_EUFLOW 0x00000002
313
314 #define TRING_ELEN 0x00004000
315 #define TRING_FDESC 0x00000200
316 #define TRING_LDESC 0x00000100
317 #define TRING_ERUNT 0x00000800
318 #define TRING_ELONG 0x00000080
319 #define TRING_EWATCHDOG 0x00000010
320 #define TRING_EDRBIT 0x00000004
321 #define TRING_ECRC 0x00000002
322 #define TRING_EOVERFLOW 0x00000001
323
324 #define TRING_RxDESCMASK (TRING_FDESC|TRING_LDESC)
325 #define TRING_RxLENGTH (TRING_ERUNT|TRING_ELONG|TRING_EWATCHDOG)
326 #define TRING_RxFRAME (TRING_EDRBIT)
327 #define TRING_RxCRC (TRING_ECRC)
328 #define TRING_RxFIFO (TRING_EOVERFLOW)
329 #define TRING_TxABORT (TRING_ETxTO|TRING_EFCOLL|TRING_ELINK)
330 #define TRING_TxCARR (TRING_ELCARR|TRING_ENCARR)
331 #define TRING_TxWINDOW (TRING_ELCOLL)
332 #define TRING_TxFIFO (TRING_EUFLOW)
333 #define TRING_TxHEARTBEAT (TRING_ENOHB)
334
335 struct tulip_rx_desc {
336 s32 status;
337 s32 length;
338 u32 buffer1, buffer2;
339 };
340
341 struct tulip_tx_desc {
342 s32 status;
343 s32 length;
344 u32 buffer1, buffer2;
345 };
346
347 struct tulip_private {
348 struct tulip_rx_desc rx_ring[RX_RING_SIZE];
349 struct tulip_tx_desc tx_ring[TX_RING_SIZE];
350
351 struct sk_buff* tx_skbuff[TX_RING_SIZE];
352 char rx_buffs[RX_RING_SIZE][PKT_BUF_SZ];
353
354 struct enet_statistics stats;
355 int setup_frame[48];
356 void (*port_select)(struct device *dev);
357 int (*port_error)(struct device *dev);
358 char *signature;
359 unsigned int cur_rx, cur_tx;
360 unsigned int dirty_rx, dirty_tx;
361 unsigned int tx_full:1;
362 unsigned int full_duplex:1;
363 };
364
365 struct eeprom {
366 union {
367 struct {
368 u_char addr[ETH_ALEN];
369 } ng;
370 struct {
371
372 u_char dum1[20];
373 u_char addr[ETH_ALEN];
374 } ok;
375 } hw;
376 #define ng_addr hw.ng.addr
377 #define ok_addr hw.ok.addr
378 #define EE_SIGNLEN 14
379 u_char sign[EE_SIGNLEN];
380 };
381
382 static int read_eeprom(int ioaddr, struct eeprom *eepp);
383 static int tulip_open(struct device *dev);
384 static void tulip_init_ring(struct device *dev);
385 static int tulip_start_xmit(struct sk_buff *skb, struct device *dev);
386 static int tulip_rx(struct device *dev);
387 static void tulip_interrupt(int irq, struct pt_regs *regs);
388 static int tulip_close(struct device *dev);
389 static struct enet_statistics *tulip_get_stats(struct device *dev);
390 static struct device *tulip_alloc(struct device *dev);
391 #if LINUX_VERSION_CODE < 0x10300
392 static void set_multicast_list(struct device *dev, int num_addrs,
393 void *addrs);
394 #else
395 static void set_multicast_list(struct device *dev);
396 #endif
397
398 #define generic21140_error NULL
399 static void generic21040_select(struct device *dev);
400 static void generic21140_select(struct device *dev);
401 static void generic21041_select(struct device *dev);
402 static void auto21140_select(struct device *dev);
403 static int generic21040_error(struct device *dev);
404 static int generic21041_error(struct device *dev);
405
406 static struct {
407 void (*port_select)(struct device *dev);
408 int (*port_error)(struct device *dev);
409 unsigned int vendor_id, device_id;
410 char *signature;
411 unsigned int port_auto:1;
412 } cardVendor[] = {
413 {generic21140_select, generic21140_error,
414 0x0000c000, PCI_DEVICE_ID_DEC_TULIP_FAST, "smc9332", 0},
415 {generic21041_select, generic21041_error,
416 0x0000c000, PCI_DEVICE_ID_DEC_TULIP_PLUS, "smc8432", 0},
417 {generic21040_select, generic21040_error,
418 0x0000c000, PCI_DEVICE_ID_DEC_TULIP, "old smc8432", 0},
419 {auto21140_select, generic21140_error,
420 0x0000f400, PCI_DEVICE_ID_DEC_TULIP_FAST, "LA100PCI", 1},
421 {generic21140_select, generic21140_error,
422 0x0000f800, PCI_DEVICE_ID_DEC_TULIP_FAST, "DE500", 0},
423 {generic21041_select, generic21041_error,
424 0x0000f800, PCI_DEVICE_ID_DEC_TULIP_PLUS, "DE450", 0},
425 {generic21040_select, generic21040_error,
426 0x0000f800, PCI_DEVICE_ID_DEC_TULIP, "DE43x", 0},
427 {generic21040_select, generic21040_error,
428 0x0040c700, PCI_DEVICE_ID_DEC_TULIP, "EN9400", 0},
429 {generic21040_select, generic21040_error,
430 0x00c09500, PCI_DEVICE_ID_DEC_TULIP, "ZNYX312", 0},
431 {generic21040_select, generic21040_error,
432 0, PCI_DEVICE_ID_DEC_TULIP, "21040", 0},
433 {generic21140_select, generic21140_error,
434 0, PCI_DEVICE_ID_DEC_TULIP_FAST, "21140", 0},
435 {generic21041_select, generic21041_error,
436 0, PCI_DEVICE_ID_DEC_TULIP_PLUS, "21041", 0},
437 {NULL, NULL, 0, 0, "Unknown", 0}
438 };
439
440
441
442
443
444 #define EE_SHIFT_CLK 0x02
445 #define EE_CS 0x01
446 #define EE_DATA_WRITE 0x04
447 #define EE_WRITE_0 0x01
448 #define EE_WRITE_1 0x05
449 #define EE_DATA_READ 0x08
450 #define EE_ENB (0x4800 | EE_CS)
451
452
453
454
455
456 #define eeprom_delay(nanosec)\
457 do { int _i = 3; while (--_i > 0) { __SLOW_DOWN_IO; }} while (0)
458
459
460 #define EE_WRITE_CMD (5 << 6)
461 #define EE_READ_CMD (6 << 6)
462 #define EE_ERASE_CMD (7 << 6)
463
464 #ifdef MODULE
465 static u_long alloc_size;
466 #endif
467
468 #ifdef __i386__
469 #define tio_write(val, port) outl(val, ioaddr + port)
470 #define tio_read(port) inl(ioaddr + port)
471 #endif
472
473 static void inline
474 tio_sia_write(u32 ioaddr, u32 val13, u32 val14, u32 val15)
475 {
476 tio_write(0,CSR13);
477 tio_write(val15,CSR15);
478 tio_write(val14,CSR14);
479 tio_write(val13,CSR13);
480 }
481
482 static char *
483 card_type(struct tulip_private *tp, int device_id, int vendor_id)
484 {
485 int n;
486
487 for (n = 0; cardVendor[n].device_id; n ++)
488 if (cardVendor[n].device_id == device_id
489 && (cardVendor[n].vendor_id == vendor_id
490 || cardVendor[n].vendor_id == 0)) break;
491 tp->port_select = cardVendor[n].port_select;
492 tp->port_error = cardVendor[n].port_error;
493 tp->signature = cardVendor[n].signature;
494 return(cardVendor[n].signature);
495 }
496
497 static int
498 read_eeprom(int ioaddr, struct eeprom *eepp)
499 {
500 int i, n;
501 unsigned short val = 0;
502 int read_cmd = EE_READ_CMD;
503 u_char *p=(u_char *)eepp;
504
505 for (n = 0; n < sizeof(struct eeprom) / 2; n ++, read_cmd ++) {
506 tio_write(EE_ENB & ~EE_CS, CSR9);
507 tio_write(EE_ENB, CSR9);
508
509
510 for (i = 10; i >= 0; i--) {
511 short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
512 tio_write(EE_ENB | dataval, CSR9);
513 eeprom_delay(100);
514 tio_write(EE_ENB | dataval | EE_SHIFT_CLK, CSR9);
515 eeprom_delay(150);
516 tio_write(EE_ENB | dataval, CSR9);
517
518 eeprom_delay(250);
519 }
520 tio_write(EE_ENB, CSR9);
521
522 for (i = 16; i > 0; i--) {
523 tio_write(EE_ENB | EE_SHIFT_CLK, CSR9);
524 eeprom_delay(100);
525 val = (val << 1)
526 | ((tio_read(CSR9) & EE_DATA_READ) ? 1 : 0);
527 tio_write(EE_ENB, CSR9);
528 eeprom_delay(100);
529 }
530
531
532 tio_write(EE_ENB & ~EE_CS, CSR9);
533 *p ++ = val;
534 *p ++ = val >> 8;
535 }
536
537 p = (u_char *)eepp;
538 for (i = 0; i < 8; i ++)
539 if (p[i] != p[15 - i] || p[i] != p[16 + i]) return(0);
540 return(-1);
541 }
542
543
544 static int
545 generic21040_error(struct device *dev)
546 {
547 int ioaddr = dev->base_addr;
548
549 return(tio_read(CSR12) & TSIAS_CONERROR);
550 }
551
552 static int
553 generic21041_error(struct device *dev)
554 {
555 int ioaddr = dev->base_addr;
556
557 return(tio_read(CSR12) & TSIAS_LNKERROR);
558 }
559
560 static void
561 generic21040_select(struct device *dev)
562 {
563 int ioaddr = dev->base_addr;
564
565 dev->if_port &= 3;
566 printk("%s: enabling %s port.\n",
567 dev->name, dev->if_port ? "AUI":"10baseT");
568
569 tio_write(FULL_DUPLEX_MAGIC, CSR11);
570 tio_write(TSIAC_RESET, CSR13);
571
572 tio_write((dev->if_port ? TSIAC_NO10TP: 0) | TSIAC_C21040, CSR13);
573 }
574
575 static void
576 generic21041_select(struct device *dev)
577 {
578 int ioaddr = dev->base_addr;
579 u32 tsiac = TSIAC_C21041;
580 u32 tsiax = TSIAX_10TP;
581 u32 tsiag = TSIAG_10TP;
582
583 printk("%s: enabling ", dev->name);
584 switch(dev->if_port) {
585 case TULIP_AUI_PORT:
586 tsiac |= TSIAC_NO10TP;
587 tsiax = TSIAX_NO10TP;
588 tsiag = TSIAG_AUI;
589 printk("AUI");
590 break;
591 case TULIP_BNC_PORT:
592 tsiac |= TSIAC_NO10TP;
593 tsiax = TSIAX_NO10TP;
594 tsiag = TSIAG_BNC;
595 printk("BNC");
596 break;
597 default:
598 dev->if_port = TULIP_10TP_PORT;
599 printk("10TP");
600 break;
601 }
602 tio_sia_write(ioaddr, tsiac, tsiax, tsiag);
603 printk(" port.\n");
604 }
605
606 static void
607 auto21140_select(struct device *dev)
608 {
609 int ioaddr = dev->base_addr;
610 struct tulip_private *tp = (struct tulip_private *)dev->priv;
611
612
613 tio_write(TPOLL_TRIGGER, CSR1);
614 tio_write(TINTR_ENABLE, CSR7);
615 tio_write(TCMOD_AUTO|TCMOD_TRxSTART, CSR6);
616 dev->if_port = !(tio_read(CSR12) & TGEPR_FORCEALED);
617 printk("%s: probed %s port.\n",
618 dev->name, dev->if_port ? "100baseTx" : "10baseT");
619 tio_write((dev->if_port ? TGEPR_FORCE100: 0)
620 | (tp->full_duplex ? 0:TGEPR_HALFDUPLEX), CSR12);
621 tio_write(TINTR_DISABLE, CSR7);
622 tio_read(CSR8) & 0xffff;
623 tio_write(TCMOD_AUTO, CSR6);
624 }
625
626 static void
627 generic21140_select(struct device *dev)
628 {
629 int ioaddr = dev->base_addr, csr6;
630 struct tulip_private *tp = (struct tulip_private *)dev->priv;
631
632 dev->if_port &= 1;
633 csr6 = tio_read(CSR6) &
634 ~(TCMOD_10TP|TCMOD_100TP|TCMOD_TRxSTART|TCMOD_SCRM);
635
636
637 tio_write(csr6 | TCMOD_RxSTART, CSR6);
638 printk("%s: enabling %s port.\n",
639 dev->name, dev->if_port ? "100baseTx" : "10baseT");
640 tio_write((dev->if_port ? TCMOD_100TP: TCMOD_10TP)
641 | TCMOD_TRxSTART | TCMOD_TH128 | csr6, CSR6);
642 tio_write((dev->if_port ? TGEPR_FORCE100: 0)
643 | (tp->full_duplex ? 0:TGEPR_HALFDUPLEX), CSR12);
644 }
645
646 static int
647 tulip_open(struct device *dev)
648 {
649 struct tulip_private *tp = (struct tulip_private *)dev->priv;
650 int ioaddr = dev->base_addr;
651
652
653 tio_write(tio_read(CSR0)|TBMOD_RESET, CSR0);
654
655 SLOW_DOWN_IO;
656
657
658
659
660 tio_write(tio_read(CSR0)|TBMOD_ALIGN32|TBMOD_BURST0, CSR0);
661
662
663 if (irq2dev_map[dev->irq] != NULL
664 || (irq2dev_map[dev->irq] = dev) == NULL
665 || dev->irq == 0
666 #if LINUX_VERSION_CODE < 0x10346
667 || request_irq(dev->irq, &tulip_interrupt, 0, tp->signature)) {
668 #else
669 || request_irq(dev->irq, (void *)&tulip_interrupt, 0,
670 tp->signature, dev)) {
671 #endif
672 return -EAGAIN;
673 }
674
675
676
677
678
679
680 tulip_init_ring(dev);
681
682
683 {
684 unsigned short *eaddrs = (unsigned short *)dev->dev_addr;
685 int *setup_frm = tp->setup_frame, i;
686
687
688 *setup_frm++ = 0xffff;
689 *setup_frm++ = 0xffff;
690 *setup_frm++ = 0xffff;
691
692 for (i = 1; i < 16; i++) {
693 *setup_frm++ = eaddrs[0];
694 *setup_frm++ = eaddrs[1];
695 *setup_frm++ = eaddrs[2];
696 }
697
698 tp->tx_ring[0].length = 0x08000000 | 192;
699 tp->tx_ring[0].buffer1 = virt_to_bus(tp->setup_frame);
700 tp->tx_ring[0].buffer2 = 0;
701 tp->tx_ring[0].status = TRING_OWN;
702
703 tp->cur_tx++, tp->dirty_tx++;
704 }
705
706 tio_write(virt_to_bus(tp->rx_ring), CSR3);
707 tio_write(virt_to_bus(tp->tx_ring), CSR4);
708
709 dev->if_port = TULIP_PORT;
710 if (tp->port_select) tp->port_select(dev);
711
712 tio_write(tio_read(CSR6) | TCMOD_TRxSTART
713 | (tp->full_duplex ? TCMOD_FULLDUPLEX:0), CSR6);
714
715
716 tio_write(TPOLL_TRIGGER, CSR1);
717
718 dev->tbusy = 0;
719 dev->interrupt = 0;
720 dev->start = 1;
721
722
723 tio_write(TINTR_ENABLE, CSR7);
724
725 MOD_INC_USE_COUNT;
726 return 0;
727 }
728
729
730 static void
731 tulip_init_ring(struct device *dev)
732 {
733 struct tulip_private *tp = (struct tulip_private *)dev->priv;
734 int i;
735
736 tp->tx_full = 0;
737 tp->cur_rx = tp->cur_tx = 0;
738 tp->dirty_rx = tp->dirty_tx = 0;
739
740 for (i = 0; i < RX_RING_SIZE; i++) {
741 tp->rx_ring[i].status = TRING_OWN;
742 tp->rx_ring[i].length = PKT_BUF_SZ;
743 tp->rx_ring[i].buffer1 = virt_to_bus(tp->rx_buffs[i]);
744 tp->rx_ring[i].buffer2 = virt_to_bus(&tp->rx_ring[i+1]);
745 }
746
747 tp->rx_ring[i-1].length = PKT_BUF_SZ | 0x02000000;
748 tp->rx_ring[i-1].buffer2 = virt_to_bus(&tp->rx_ring[0]);
749
750
751
752 for (i = 0; i < TX_RING_SIZE; i++) {
753 tp->tx_ring[i].status = 0x00000000;
754 }
755 }
756
757 static int
758 tulip_start_xmit(struct sk_buff *skb, struct device *dev)
759 {
760 struct tulip_private *tp = (struct tulip_private *)dev->priv;
761 int ioaddr = dev->base_addr;
762 int entry;
763
764
765 if (dev->tbusy) {
766 int tickssofar = jiffies - dev->trans_start;
767 int i;
768 if (tickssofar < 40) return(1);
769 if (tp->port_select
770 && (!tp->port_error || tp->port_error(dev))) {
771 dev->if_port ++;
772 tp->port_select(dev);
773 dev->trans_start = jiffies;
774 return(0);
775 }
776 printk("%s: transmit timed out, status %8.8x,"
777 "SIA %8.8x %8.8x %8.8x %8.8x, resetting...\n",
778 dev->name, tio_read(CSR5), tio_read(CSR12),
779 tio_read(CSR13), tio_read(CSR14), tio_read(CSR15));
780 printk(" Rx ring %8.8x: ", (int)tp->rx_ring);
781 for (i = 0; i < RX_RING_SIZE; i++)
782 printk(" %8.8x", (unsigned int)tp->rx_ring[i].status);
783 printk("\n Tx ring %8.8x: ", (int)tp->tx_ring);
784 for (i = 0; i < TX_RING_SIZE; i++)
785 printk(" %8.8x", (unsigned int)tp->tx_ring[i].status);
786 printk("\n");
787
788 tp->stats.tx_errors++;
789
790 dev->if_port = 0;
791 tio_write(TSIAC_CONFIG, CSR13);
792
793 tio_write(TCMOD_10TP | TCMOD_TRxSTART, CSR6);
794
795 tio_write(TPOLL_TRIGGER, CSR1);
796
797 dev->tbusy=0;
798 dev->trans_start = jiffies;
799 return(0);
800 }
801
802 if (skb == NULL || skb->len <= 0) {
803 printk("%s: Obsolete driver layer request made: skbuff==NULL.\n",
804 dev->name);
805 dev_tint(dev);
806 return(0);
807 }
808
809
810
811
812 if (set_bit(0, (void*)&dev->tbusy) != 0) {
813 printk("%s: Transmitter access conflict.\n", dev->name);
814 return 1;
815 }
816
817
818
819
820
821 entry = tp->cur_tx % TX_RING_SIZE;
822
823 tp->tx_full = 1;
824 tp->tx_skbuff[entry] = skb;
825 tp->tx_ring[entry].length = skb->len |
826 (entry == TX_RING_SIZE-1 ? 0xe2000000 : 0xe0000000);
827 tp->tx_ring[entry].buffer1 = virt_to_bus(skb->data);
828 tp->tx_ring[entry].buffer2 = 0;
829 tp->tx_ring[entry].status = TRING_OWN;
830
831 tp->cur_tx++;
832
833
834 tio_write(TPOLL_TRIGGER, CSR1);
835
836 dev->trans_start = jiffies;
837
838 return(0);
839 }
840
841
842
843 static void tulip_interrupt(int irq, struct pt_regs *regs)
844 {
845 struct device *dev = (struct device *)(irq2dev_map[irq]);
846 struct tulip_private *lp;
847 int csr5, ioaddr, boguscnt=10;
848
849 if (dev == NULL) {
850 printk ("tulip_interrupt(): irq %d for unknown device.\n", irq);
851 return;
852 }
853
854 ioaddr = dev->base_addr;
855 lp = (struct tulip_private *)dev->priv;
856 if (dev->interrupt)
857 printk("%s: Re-entering the interrupt handler.\n", dev->name);
858
859 dev->interrupt = 1;
860
861 do {
862 csr5 = tio_read(CSR5);
863
864 tio_write(csr5 & TSTAT_CLEARINTR, CSR5);
865
866
867 if ((csr5 & (TSTAT_NORINTR|TSTAT_ABNINTR)) == 0) break;
868
869 if (csr5 & TSTAT_RxINTR)
870 tulip_rx(dev);
871
872 if (csr5 & TSTAT_TxINTR) {
873 int dirty_tx = lp->dirty_tx;
874
875 while (dirty_tx < lp->cur_tx) {
876 int entry = dirty_tx % TX_RING_SIZE;
877 int status = lp->tx_ring[entry].status;
878
879 if (status < 0)
880 break;
881
882 if (status & TRING_ERROR) {
883
884 lp->stats.tx_errors++;
885 if (status & TRING_TxABORT) lp->stats.tx_aborted_errors++;
886 if (status & TRING_TxCARR) lp->stats.tx_carrier_errors++;
887 if (status & TRING_TxWINDOW) lp->stats.tx_window_errors++;
888 if (status & TRING_TxFIFO) lp->stats.tx_fifo_errors++;
889 if ((status & TRING_TxHEARTBEAT) && !lp->full_duplex)
890 lp->stats.tx_heartbeat_errors++;
891 #ifdef ETHER_STATS
892 if (status & 0x0100) lp->stats.collisions16++;
893 #endif
894 } else {
895 #ifdef ETHER_STATS
896 if (status & 0x0001) lp->stats.tx_deferred++;
897 #endif
898 lp->stats.collisions += (status >> 3) & 15;
899 lp->stats.tx_packets++;
900 }
901
902
903 dev_kfree_skb(lp->tx_skbuff[entry], FREE_WRITE);
904 dirty_tx++;
905 }
906
907 #ifndef final_version
908 if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) {
909 printk("out-of-sync dirty pointer, %d vs. %d, full=%d.\n",
910 dirty_tx, lp->cur_tx, lp->tx_full);
911 dirty_tx += TX_RING_SIZE;
912 }
913 #endif
914
915 if (lp->tx_full && dev->tbusy
916 && dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
917
918 lp->tx_full = 0;
919 dev->tbusy = 0;
920 mark_bh(NET_BH);
921 }
922
923 lp->dirty_tx = dirty_tx;
924 }
925
926
927 if (csr5 & TSTAT_ABNINTR) {
928 if (csr5 & TSTAT_TxTOUT) lp->stats.tx_errors++;
929 if (csr5 & TSTAT_RxMISSED) {
930 lp->stats.rx_errors++;
931 lp->stats.rx_missed_errors += tio_read(CSR8) & 0xffff;
932 }
933 if (csr5 & TSTAT_TEXPIRED) {
934 printk("%s: Something Wicked happened! %8.8x.\n",
935 dev->name, csr5);
936
937 }
938 }
939 if (--boguscnt < 0) {
940 printk("%s: Too much work at interrupt, csr5=0x%8.8x.\n",
941 dev->name, csr5);
942
943 tio_write(TSTAT_CLEARINTR, CSR5);
944 break;
945 }
946 } while (1);
947
948
949 {
950 static int stopit = 10;
951 if (dev->start == 0 && --stopit < 0) {
952 printk("%s: Emergency stop, looping startup interrupt.\n",
953 dev->name);
954 #if LINUX_VERSION_CODE < 0x10346
955 free_irq(irq);
956 #else
957 free_irq(irq, dev);
958 #endif
959 }
960 }
961
962 dev->interrupt = 0;
963 return;
964 }
965
966 static int
967 tulip_rx(struct device *dev)
968 {
969 struct tulip_private *lp = (struct tulip_private *)dev->priv;
970 int entry = lp->cur_rx % RX_RING_SIZE;
971 int i;
972
973
974 while (lp->rx_ring[entry].status >= 0) {
975 int status = lp->rx_ring[entry].status;
976
977 if ((status & TRING_RxDESCMASK) != TRING_RxDESCMASK) {
978 printk("%s: Ethernet frame spanned multiple buffers,"
979 "status %8.8x!\n", dev->name, status);
980 } else if (status & TRING_ERROR) {
981
982 lp->stats.rx_errors++;
983 if (status & TRING_RxLENGTH) lp->stats.rx_length_errors++;
984 if (status & TRING_RxFRAME) lp->stats.rx_frame_errors++;
985 if (status & TRING_RxCRC) lp->stats.rx_crc_errors++;
986 if (status & TRING_RxFIFO) lp->stats.rx_fifo_errors++;
987 } else {
988
989 short pkt_len = lp->rx_ring[entry].status >> 16;
990 struct sk_buff *skb;
991
992 #if LINUX_VERSION_CODE < 0x10300
993 skb = alloc_skb(pkt_len, GFP_ATOMIC);
994 #else
995 skb = dev_alloc_skb(pkt_len + 2);
996 #endif
997 if (skb == NULL) {
998 printk("%s: Memory squeeze, deferring packet.\n",
999 dev->name);
1000
1001
1002 for (i=0; i < RX_RING_SIZE; i++)
1003 if (lp->rx_ring[(entry+i) % RX_RING_SIZE].status < 0)
1004 break;
1005
1006 if (i > RX_RING_SIZE -2) {
1007 lp->stats.rx_dropped++;
1008 lp->rx_ring[entry].status = TRING_OWN;
1009 lp->cur_rx++;
1010 }
1011 break;
1012 }
1013 skb->dev = dev;
1014 #if LINUX_VERSION_CODE < 0x10300
1015 skb->len = pkt_len;
1016 memcpy(skb->data, bus_to_virt(lp->rx_ring[entry].buffer1),
1017 pkt_len);
1018 #else
1019 skb_reserve(skb, 2);
1020 memcpy(skb_put(skb, pkt_len),
1021 bus_to_virt(lp->rx_ring[entry].buffer1), pkt_len);
1022
1023 skb->protocol = eth_type_trans(skb,dev);
1024 #endif
1025 netif_rx(skb);
1026 lp->stats.rx_packets++;
1027 }
1028
1029 lp->rx_ring[entry].status = TRING_OWN;
1030 entry = (++lp->cur_rx) % RX_RING_SIZE;
1031 }
1032 return(0);
1033 }
1034
1035 static int
1036 tulip_close(struct device *dev)
1037 {
1038 int ioaddr = dev->base_addr;
1039 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1040
1041 dev->start = 0;
1042 dev->tbusy = 1;
1043
1044
1045 tio_write(TINTR_DISABLE, CSR7);
1046
1047 tio_write(tio_read(CSR6) & ~(TCMOD_TRxSTART), CSR6);
1048
1049 tio_write(TSIAC_CONFIG, CSR13);
1050
1051 tp->stats.rx_missed_errors += tio_read(CSR8) & 0xffff;
1052
1053 tio_write(0, CSR13);
1054
1055
1056 #if LINUX_VERSION_CODE < 0x10346
1057 free_irq(dev->irq);
1058 #else
1059 free_irq(dev->irq, dev);
1060 #endif
1061 irq2dev_map[dev->irq] = 0;
1062
1063 MOD_DEC_USE_COUNT;
1064 return(0);
1065 }
1066
1067 static struct enet_statistics *
1068 tulip_get_stats(struct device *dev)
1069 {
1070 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1071 short ioaddr = dev->base_addr;
1072
1073 tp->stats.rx_missed_errors += tio_read(CSR8) & 0xffff;
1074
1075 return(&tp->stats);
1076 }
1077
1078
1079
1080
1081
1082 #if LINUX_VERSION_CODE < 0x10300
1083 static void set_multicast_list(struct device *dev, int num_addrs,
1084 void *addrs)
1085 #else
1086 static void set_multicast_list(struct device *dev)
1087 #endif
1088 {
1089 short ioaddr = dev->base_addr;
1090 int csr6 = tio_read(CSR6) & ~(TCMOD_MODEMASK|TCMOD_FILTERMASK);
1091
1092 if (dev->flags&IFF_PROMISC)
1093 {
1094 tio_write(csr6 | TCMOD_PROMISC | TCMOD_ALLMCAST, CSR6);
1095
1096 printk("%s: Promiscuous mode enabled.\n", dev->name);
1097 }
1098 else if (dev->mc_count > 15 || (dev->flags&IFF_ALLMULTI))
1099 {
1100
1101 tio_write(csr6 | TCMOD_ALLMCAST, CSR6);
1102 }
1103 else
1104 {
1105 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1106 struct dev_mc_list *dmi=dev->mc_list;
1107 int *setup_frm = tp->setup_frame;
1108 unsigned short *eaddrs;
1109 int i;
1110
1111
1112
1113
1114 tio_write(csr6 | 0x0000, CSR6);
1115 i=0;
1116 while(dmi)
1117 {
1118 eaddrs=(unsigned short *)dmi->dmi_addr;
1119 dmi=dmi->next;
1120 i++;
1121 *setup_frm++ = *eaddrs++;
1122 *setup_frm++ = *eaddrs++;
1123 *setup_frm++ = *eaddrs++;
1124 }
1125
1126 eaddrs = (unsigned short *)dev->dev_addr;
1127 do {
1128 *setup_frm++ = eaddrs[0];
1129 *setup_frm++ = eaddrs[1];
1130 *setup_frm++ = eaddrs[2];
1131 } while (++i < 16);
1132
1133
1134 }
1135 }
1136
1137 #if 0
1138 static int
1139 set_mac_address(struct device *dev, void *addr)
1140 {
1141 int i;
1142 struct sockaddr *sa=(struct sockaddr *)addr;
1143 if (dev->start)
1144 return -EBUSY;
1145 printk("%s: Setting MAC address to ", dev->name);
1146 for (i = 0; i < ETH_ALEN - 1; i++)
1147 printk("%2.2x:", dev->dev_addr[i] = sa->sa_data[i]);
1148 printk("%2.2x.\n", dev->dev_addr[i] = sa->sa_data[i]);
1149 return 0;
1150 }
1151 #endif
1152
1153 static struct device *tulip_alloc(struct device *dev)
1154 {
1155 struct tulip_private *tp;
1156 char *buff;
1157 #ifndef MODULE
1158 int alloc_size;
1159 #endif
1160 if (!dev || dev->priv) {
1161 struct device *olddev = dev;
1162
1163 alloc_size = sizeof(struct device)
1164 + sizeof(struct tulip_private)
1165 + ETHNAMSIZ;
1166 alloc_size = ROUND_UP(alloc_size, 8);
1167
1168 buff = (char *)kmalloc(alloc_size, GFP_KERNEL);
1169 dev = (struct device *)buff;
1170 if (dev == NULL) {
1171 printk("tulip_alloc: kmalloc failed.\n");
1172 return(NULL);
1173 }
1174 tp = (struct tulip_private *)(buff + sizeof(struct device));
1175 memset(buff, 0, alloc_size);
1176 dev->priv = (void *)tp;
1177 dev->name = (char *)(buff + sizeof(struct device)
1178 + sizeof(struct tulip_private));
1179 if (olddev) {
1180 dev->next = olddev->next;
1181 olddev->next = dev;
1182 }
1183 } else {
1184 alloc_size = ROUND_UP(sizeof(struct tulip_private), 8);
1185 tp = (struct tulip_private *)kmalloc(alloc_size, GFP_KERNEL);
1186 memset((void *)tp, 0, alloc_size);
1187 dev->priv = (void *)tp;
1188 }
1189 return(dev);
1190 }
1191
1192 int
1193 tulip_hwinit(struct device *dev, int ioaddr,
1194 int irq, int device_id)
1195 {
1196
1197 unsigned char last_phys_addr[6] = {0x00, 'L', 'i', 'n', 'u', 'x'};
1198 char detect_mesg[80], *mesgp=detect_mesg, *card_name=NULL;
1199 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1200 int i;
1201 unsigned short sum, bitsum;
1202
1203 if (check_region(ioaddr, TULIP_TOTAL_SIZE) != 0) {
1204 printk("tulip_alloc: region already allocated at %#3x.\n",
1205 ioaddr);
1206 return(-1);
1207 }
1208
1209 mesgp += sprintf(mesgp, "(DEC 21%d4%d Tulip",
1210 device_id == PCI_DEVICE_ID_DEC_TULIP_FAST,
1211 device_id == PCI_DEVICE_ID_DEC_TULIP_PLUS);
1212
1213
1214 tio_write(tio_read(CSR6) & ~TCMOD_TRxSTART, CSR6);
1215
1216 tio_read(CSR8) & 0xffff;
1217
1218 if (device_id == PCI_DEVICE_ID_DEC_TULIP_PLUS
1219 && (tio_read(CSR9) & 0x8000)) {
1220 mesgp += sprintf(mesgp, "treat as 21040 ");
1221 device_id = PCI_DEVICE_ID_DEC_TULIP;
1222 }
1223
1224
1225
1226
1227
1228 sum = 0;
1229 if (device_id == PCI_DEVICE_ID_DEC_TULIP) {
1230 tio_write(0, CSR9);
1231
1232 bitsum = 0xff;
1233 for (i = 0; i < 6; i++) {
1234 int value, boguscnt = 100000;
1235 do
1236 value = tio_read(CSR9);
1237 while (value < 0 && --boguscnt > 0);
1238 dev->dev_addr[i] = value;
1239 sum += value;
1240 bitsum &= value;
1241 }
1242 } else {
1243
1244 struct eeprom eep;
1245 u_char *addr;
1246
1247 if (read_eeprom(ioaddr, &eep) < 0) {
1248 addr = eep.ng_addr;
1249 } else {
1250 addr = eep.ok_addr;
1251 }
1252 for (i = 0; i < ETH_ALEN; i++) {
1253 sum += addr[i];
1254 dev->dev_addr[i] = addr[i];
1255 }
1256 }
1257
1258
1259 mesgp += sprintf(mesgp, ") at %#3x, ", ioaddr);
1260
1261
1262
1263 if (sum == 0) {
1264 for (i = 0; i < ETH_ALEN - 1; i++)
1265 dev->dev_addr[i] = last_phys_addr[i];
1266 dev->dev_addr[i] = last_phys_addr[i] + 1;
1267 }
1268 for (i = 0; i < ETH_ALEN - 1; i++)
1269 mesgp += sprintf(mesgp, "%2.2x:",
1270 last_phys_addr[i] = dev->dev_addr[i]);
1271 mesgp += sprintf(mesgp, "%2.2x, IRQ %d\n",
1272 last_phys_addr[i] = dev->dev_addr[i], irq);
1273
1274 card_name = card_type(tp, device_id,
1275 htonl((*(int*)dev->dev_addr) & 0xFFFFFF));
1276
1277
1278 request_region(ioaddr, TULIP_TOTAL_SIZE, tp->signature);
1279
1280 dev->base_addr = ioaddr;
1281 dev->irq = irq;
1282
1283 #ifdef TULIP_FULL_DUPLEX
1284 tp->full_duplex = 1;
1285 #endif
1286
1287
1288 dev->open = &tulip_open;
1289 dev->hard_start_xmit = &tulip_start_xmit;
1290 dev->stop = &tulip_close;
1291 dev->get_stats = &tulip_get_stats;
1292 dev->set_multicast_list = &set_multicast_list;
1293 #if 0
1294 dev->set_mac_address = &set_mac_address;
1295 #endif
1296
1297 #ifdef MODULE
1298 ether_setup(dev);
1299 #else
1300 init_etherdev(dev, 0);
1301 #endif
1302
1303 printk("%s: %s %s", dev->name, card_name, detect_mesg);
1304
1305
1306 tio_write(TSIAC_RESET, CSR13);
1307 tio_write(TSIAC_CONFIG, CSR13);
1308
1309 return(0);
1310 }
1311
1312 int tulip_probe(struct device *dev)
1313 {
1314 static u_short probed_irqs=0;
1315 u_char pci_bus, pci_device_fn, pci_latency, pci_irq;
1316 u_int pci_ioaddr;
1317 u_short pci_command;
1318 u_long pci_chips[] = {
1319 PCI_DEVICE_ID_DEC_TULIP,
1320 PCI_DEVICE_ID_DEC_TULIP_FAST,
1321 PCI_DEVICE_ID_DEC_TULIP_PLUS,
1322 PCI_DEVICE_ID_NONE
1323 };
1324 int num=0, cno;
1325 int pci_index;
1326
1327 if (!pcibios_present()) return(-ENODEV);
1328
1329 for (pci_index = 0; pci_index < 8; pci_index++) {
1330
1331 for (cno = 0; pci_chips[cno] != PCI_DEVICE_ID_NONE; cno ++)
1332 if (pcibios_find_device(PCI_VENDOR_ID_DEC,
1333 pci_chips[cno],
1334 pci_index, &pci_bus,
1335 &pci_device_fn) == 0) {
1336
1337 pcibios_read_config_byte(pci_bus, pci_device_fn,
1338 PCI_INTERRUPT_LINE, &pci_irq);
1339 if (probed_irqs & (1 << pci_irq)) continue;
1340
1341 pcibios_read_config_dword(pci_bus, pci_device_fn,
1342 PCI_BASE_ADDRESS_0,
1343 &pci_ioaddr);
1344
1345 pci_ioaddr &= ~3;
1346 #ifdef MODULE
1347
1348 if (dev && dev->irq && dev->base_addr &&
1349 (dev->irq != pci_irq
1350 || dev->base_addr != pci_ioaddr)) continue;
1351 #else
1352 if ((dev = tulip_alloc(dev)) == NULL) break;
1353 #endif
1354 if (!probed_irqs) printk(version);
1355 probed_irqs |= (1 << pci_irq);
1356
1357
1358 pcibios_read_config_word(pci_bus, pci_device_fn,
1359 PCI_COMMAND, &pci_command);
1360 if ( ! (pci_command & PCI_COMMAND_MASTER)) {
1361 printk(" PCI Master Bit has not been set!"
1362 " Setting...\n");
1363 pci_command |= PCI_COMMAND_MASTER;
1364 pcibios_write_config_word(pci_bus, pci_device_fn,
1365 PCI_COMMAND, pci_command);
1366 }
1367 pcibios_read_config_byte(pci_bus, pci_device_fn,
1368 PCI_LATENCY_TIMER,
1369 &pci_latency);
1370 if (pci_latency < 10) {
1371 printk(" PCI latency timer (CFLT) is"
1372 " unreasonably low at %d."
1373 " Setting to 100 clocks.\n", pci_latency);
1374 pcibios_write_config_byte(pci_bus, pci_device_fn,
1375 PCI_LATENCY_TIMER, 100);
1376 }
1377 if (tulip_hwinit(dev, pci_ioaddr, pci_irq,
1378 pci_chips[cno]) < 0) continue;
1379 num ++;
1380 #if defined(MODULE) || defined(TULIP_ONLY_ONE)
1381 return(0);
1382 #endif
1383 }
1384 }
1385 return(num > 0 ? 0: -ENODEV);
1386 }
1387
1388 #ifdef MODULE
1389 static int io = 0xfc00;
1390 static int irq = 9;
1391
1392 static struct device *mod_dev;
1393
1394 int init_module(void)
1395 {
1396 if ((mod_dev = tulip_alloc(0)) == NULL) return(-EIO);
1397
1398 mod_dev->base_addr = io;
1399 mod_dev->irq = irq;
1400 mod_dev->init = &tulip_probe;
1401
1402 if (register_netdev(mod_dev)) {
1403 printk("tulip: register_netdev() returned non-zero.\n");
1404 kfree_s(mod_dev, alloc_size);
1405 return -EIO;
1406 }
1407 return(0);
1408 }
1409
1410 void
1411 cleanup_module(void)
1412 {
1413 release_region(mod_dev->base_addr, TULIP_TOTAL_SIZE);
1414 unregister_netdev(mod_dev);
1415 kfree_s(mod_dev, alloc_size);
1416 }
1417
1418 #endif
1419
1420
1421
1422
1423
1424
1425
1426
1427