More meth updates.
[linux-2.6/linux-mips.git] / drivers / net / Space.c
blob838c59729c711eade4223b2fba7959eb8f2db1c1
1 /*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * Holds initial configuration information for devices.
8 * Version: @(#)Space.c 1.0.7 08/12/93
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Donald J. Becker, <becker@scyld.com>
14 * Changelog:
15 * Paul Gortmaker (03/2002)
16 - struct init cleanup, enable multiple ISA autoprobes.
17 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 09/1999
18 * - fix sbni: s/device/net_device/
19 * Paul Gortmaker (06/98):
20 * - sort probes in a sane way, make sure all (safe) probes
21 * get run once & failed autoprobes don't autoprobe again.
23 * FIXME:
24 * Phase out placeholder dev entries put in the linked list
25 * here in favour of drivers using init_etherdev(NULL, ...)
26 * combined with a single find_all_devs() function (for 2.3)
28 * This program is free software; you can redistribute it and/or
29 * modify it under the terms of the GNU General Public License
30 * as published by the Free Software Foundation; either version
31 * 2 of the License, or (at your option) any later version.
33 #include <linux/config.h>
34 #include <linux/netdevice.h>
35 #include <linux/errno.h>
36 #include <linux/init.h>
37 #include <linux/netlink.h>
38 #include <linux/divert.h>
40 #define NEXT_DEV NULL
43 /* A unified ethernet device probe. This is the easiest way to have every
44 ethernet adaptor have the name "eth[0123...]".
47 extern int ne2_probe(struct net_device *dev);
48 extern int hp100_probe(struct net_device *dev);
49 extern int ultra_probe(struct net_device *dev);
50 extern int ultra32_probe(struct net_device *dev);
51 extern int wd_probe(struct net_device *dev);
52 extern int el2_probe(struct net_device *dev);
53 extern int ne_probe(struct net_device *dev);
54 extern int hp_probe(struct net_device *dev);
55 extern int hp_plus_probe(struct net_device *dev);
56 extern int express_probe(struct net_device *);
57 extern int eepro_probe(struct net_device *);
58 extern int at1500_probe(struct net_device *);
59 extern int at1700_probe(struct net_device *);
60 extern int fmv18x_probe(struct net_device *);
61 extern int eth16i_probe(struct net_device *);
62 extern int depca_probe(struct net_device *);
63 extern int i82596_probe(struct net_device *);
64 extern int ewrk3_probe(struct net_device *);
65 extern int de4x5_probe(struct net_device *);
66 extern int el1_probe(struct net_device *);
67 extern int wavelan_probe(struct net_device *);
68 extern int arlan_probe(struct net_device *);
69 extern int el16_probe(struct net_device *);
70 extern int elmc_probe(struct net_device *);
71 extern int skmca_probe(struct net_device *);
72 extern int elplus_probe(struct net_device *);
73 extern int ac3200_probe(struct net_device *);
74 extern int es_probe(struct net_device *);
75 extern int lne390_probe(struct net_device *);
76 extern int ne3210_probe(struct net_device *);
77 extern int e2100_probe(struct net_device *);
78 extern int ni5010_probe(struct net_device *);
79 extern int ni52_probe(struct net_device *);
80 extern int ni65_probe(struct net_device *);
81 extern int sonic_probe(struct net_device *);
82 extern int SK_init(struct net_device *);
83 extern int seeq8005_probe(struct net_device *);
84 extern int smc_init( struct net_device * );
85 extern int atarilance_probe(struct net_device *);
86 extern int sun3lance_probe(struct net_device *);
87 extern int sun3_82586_probe(struct net_device *);
88 extern int apne_probe(struct net_device *);
89 extern int bionet_probe(struct net_device *);
90 extern int pamsnet_probe(struct net_device *);
91 extern int cs89x0_probe(struct net_device *dev);
92 extern int ethertap_probe(struct net_device *dev);
93 extern int hplance_probe(struct net_device *dev);
94 extern int bagetlance_probe(struct net_device *);
95 extern int mvme147lance_probe(struct net_device *dev);
96 extern int tc515_probe(struct net_device *dev);
97 extern int lance_probe(struct net_device *dev);
98 extern int mace_probe(struct net_device *dev);
99 extern int macsonic_probe(struct net_device *dev);
100 extern int mac8390_probe(struct net_device *dev);
101 extern int mac89x0_probe(struct net_device *dev);
102 extern int mc32_probe(struct net_device *dev);
104 /* Detachable devices ("pocket adaptors") */
105 extern int de620_probe(struct net_device *);
107 /* Fibre Channel adapters */
108 extern int iph5526_probe(struct net_device *dev);
110 /* SBNI adapters */
111 extern int sbni_probe(struct net_device *);
113 struct devprobe
115 int (*probe)(struct net_device *dev);
116 int status; /* non-zero if autoprobe has failed */
120 * probe_list walks a list of probe functions and calls each so long
121 * as a non-zero ioaddr is given, or as long as it hasn't already failed
122 * to find a card in the past (as recorded by "status") when asked to
123 * autoprobe (i.e. a probe that fails to find a card when autoprobing
124 * will not be asked to autoprobe again). It exits when a card is found.
126 static int __init probe_list(struct net_device *dev, struct devprobe *plist)
128 struct devprobe *p = plist;
129 unsigned long base_addr = dev->base_addr;
130 int ret;
132 while (p->probe != NULL) {
133 if (base_addr && p->probe(dev) == 0) { /* probe given addr */
134 ret = alloc_divert_blk(dev);
135 if (ret)
136 return ret;
137 return 0;
138 } else if (p->status == 0) { /* has autoprobe failed yet? */
139 p->status = p->probe(dev); /* no, try autoprobe */
140 if (p->status == 0) {
141 ret = alloc_divert_blk(dev);
142 if (ret)
143 return ret;
144 return 0;
147 p++;
149 return -ENODEV;
153 * This is a bit of an artificial separation as there are PCI drivers
154 * that also probe for EISA cards (in the PCI group) and there are ISA
155 * drivers that probe for EISA cards (in the ISA group). These are the
156 * EISA only driver probes, and also the legacy PCI probes
158 static struct devprobe eisa_probes[] __initdata = {
159 #ifdef CONFIG_DE4X5 /* DEC DE425, DE434, DE435 adapters */
160 {de4x5_probe, 0},
161 #endif
162 #ifdef CONFIG_ULTRA32
163 {ultra32_probe, 0},
164 #endif
165 #ifdef CONFIG_AC3200
166 {ac3200_probe, 0},
167 #endif
168 #ifdef CONFIG_ES3210
169 {es_probe, 0},
170 #endif
171 #ifdef CONFIG_LNE390
172 {lne390_probe, 0},
173 #endif
174 #ifdef CONFIG_NE3210
175 {ne3210_probe, 0},
176 #endif
177 {NULL, 0},
181 static struct devprobe mca_probes[] __initdata = {
182 #ifdef CONFIG_NE2_MCA
183 {ne2_probe, 0},
184 #endif
185 #ifdef CONFIG_ELMC /* 3c523 */
186 {elmc_probe, 0},
187 #endif
188 #ifdef CONFIG_ELMC_II /* 3c527 */
189 {mc32_probe, 0},
190 #endif
191 #ifdef CONFIG_SKMC /* SKnet Microchannel */
192 {skmca_probe, 0},
193 #endif
194 {NULL, 0},
198 * ISA probes that touch addresses < 0x400 (including those that also
199 * look for EISA/PCI/MCA cards in addition to ISA cards).
201 static struct devprobe isa_probes[] __initdata = {
202 #ifdef CONFIG_HP100 /* ISA, EISA & PCI */
203 {hp100_probe, 0},
204 #endif
205 #ifdef CONFIG_3C515
206 {tc515_probe, 0},
207 #endif
208 #ifdef CONFIG_ULTRA
209 {ultra_probe, 0},
210 #endif
211 #ifdef CONFIG_WD80x3
212 {wd_probe, 0},
213 #endif
214 #ifdef CONFIG_EL2 /* 3c503 */
215 {el2_probe, 0},
216 #endif
217 #ifdef CONFIG_HPLAN
218 {hp_probe, 0},
219 #endif
220 #ifdef CONFIG_HPLAN_PLUS
221 {hp_plus_probe, 0},
222 #endif
223 #ifdef CONFIG_E2100 /* Cabletron E21xx series. */
224 {e2100_probe, 0},
225 #endif
226 #if defined(CONFIG_NE2000) || defined(CONFIG_NE2K_CBUS) /* ISA & PC-9800 CBUS (use ne2k-pci for PCI cards) */
227 {ne_probe, 0},
228 #endif
229 #ifdef CONFIG_LANCE /* ISA/VLB (use pcnet32 for PCI cards) */
230 {lance_probe, 0},
231 #endif
232 #ifdef CONFIG_SMC9194
233 {smc_init, 0},
234 #endif
235 #ifdef CONFIG_SEEQ8005
236 {seeq8005_probe, 0},
237 #endif
238 #ifdef CONFIG_AT1500
239 {at1500_probe, 0},
240 #endif
241 #ifdef CONFIG_CS89x0
242 {cs89x0_probe, 0},
243 #endif
244 #ifdef CONFIG_AT1700
245 {at1700_probe, 0},
246 #endif
247 #ifdef CONFIG_FMV18X /* Fujitsu FMV-181/182 */
248 {fmv18x_probe, 0},
249 #endif
250 #ifdef CONFIG_ETH16I
251 {eth16i_probe, 0}, /* ICL EtherTeam 16i/32 */
252 #endif
253 #ifdef CONFIG_EEXPRESS /* Intel EtherExpress */
254 {express_probe, 0},
255 #endif
256 #ifdef CONFIG_EEXPRESS_PRO /* Intel EtherExpress Pro/10 */
257 {eepro_probe, 0},
258 #endif
259 #ifdef CONFIG_DEPCA /* DEC DEPCA */
260 {depca_probe, 0},
261 #endif
262 #ifdef CONFIG_EWRK3 /* DEC EtherWORKS 3 */
263 {ewrk3_probe, 0},
264 #endif
265 #if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET) /* Intel I82596 */
266 {i82596_probe, 0},
267 #endif
268 #ifdef CONFIG_EL1 /* 3c501 */
269 {el1_probe, 0},
270 #endif
271 #ifdef CONFIG_WAVELAN /* WaveLAN */
272 {wavelan_probe, 0},
273 #endif
274 #ifdef CONFIG_ARLAN /* Aironet */
275 {arlan_probe, 0},
276 #endif
277 #ifdef CONFIG_EL16 /* 3c507 */
278 {el16_probe, 0},
279 #endif
280 #ifdef CONFIG_ELPLUS /* 3c505 */
281 {elplus_probe, 0},
282 #endif
283 #ifdef CONFIG_SK_G16
284 {SK_init, 0},
285 #endif
286 #ifdef CONFIG_NI5010
287 {ni5010_probe, 0},
288 #endif
289 #ifdef CONFIG_NI52
290 {ni52_probe, 0},
291 #endif
292 #ifdef CONFIG_NI65
293 {ni65_probe, 0},
294 #endif
295 {NULL, 0},
298 static struct devprobe parport_probes[] __initdata = {
299 #ifdef CONFIG_DE620 /* D-Link DE-620 adapter */
300 {de620_probe, 0},
301 #endif
302 {NULL, 0},
305 static struct devprobe m68k_probes[] __initdata = {
306 #ifdef CONFIG_ATARILANCE /* Lance-based Atari ethernet boards */
307 {atarilance_probe, 0},
308 #endif
309 #ifdef CONFIG_SUN3LANCE /* sun3 onboard Lance chip */
310 {sun3lance_probe, 0},
311 #endif
312 #ifdef CONFIG_SUN3_82586 /* sun3 onboard Intel 82586 chip */
313 {sun3_82586_probe, 0},
314 #endif
315 #ifdef CONFIG_APNE /* A1200 PCMCIA NE2000 */
316 {apne_probe, 0},
317 #endif
318 #ifdef CONFIG_ATARI_BIONET /* Atari Bionet Ethernet board */
319 {bionet_probe, 0},
320 #endif
321 #ifdef CONFIG_ATARI_PAMSNET /* Atari PAMsNet Ethernet board */
322 {pamsnet_probe, 0},
323 #endif
324 #ifdef CONFIG_HPLANCE /* HP300 internal Ethernet */
325 {hplance_probe, 0},
326 #endif
327 #ifdef CONFIG_MVME147_NET /* MVME147 internal Ethernet */
328 {mvme147lance_probe, 0},
329 #endif
330 #ifdef CONFIG_MACMACE /* Mac 68k Quadra AV builtin Ethernet */
331 {mace_probe, 0},
332 #endif
333 #ifdef CONFIG_MACSONIC /* Mac SONIC-based Ethernet of all sorts */
334 {macsonic_probe, 0},
335 #endif
336 #ifdef CONFIG_MAC8390 /* NuBus NS8390-based cards */
337 {mac8390_probe, 0},
338 #endif
339 #ifdef CONFIG_MAC89x0
340 {mac89x0_probe, 0},
341 #endif
342 {NULL, 0},
345 static struct devprobe mips_probes[] __initdata = {
346 #ifdef CONFIG_MIPS_JAZZ_SONIC
347 {sonic_probe, 0},
348 #endif
349 #ifdef CONFIG_BAGETLANCE /* Lance-based Baget ethernet boards */
350 {bagetlance_probe, 0},
351 #endif
352 {NULL, 0},
356 * Unified ethernet device probe, segmented per architecture and
357 * per bus interface. This drives the legacy devices only for now.
360 static int __init ethif_probe(struct net_device *dev)
362 unsigned long base_addr = dev->base_addr;
365 * Backwards compatibility - historically an I/O base of 1 was
366 * used to indicate not to probe for this ethN interface
368 if (base_addr == 1)
369 return 1; /* ENXIO */
372 * The arch specific probes are 1st so that any on-board ethernet
373 * will be probed before other ISA/EISA/MCA/PCI bus cards.
375 if (probe_list(dev, m68k_probes) == 0)
376 return 0;
377 if (probe_list(dev, mips_probes) == 0)
378 return 0;
379 if (probe_list(dev, eisa_probes) == 0)
380 return 0;
381 if (probe_list(dev, mca_probes) == 0)
382 return 0;
383 if (probe_list(dev, isa_probes) == 0)
384 return 0;
385 if (probe_list(dev, parport_probes) == 0)
386 return 0;
387 return -ENODEV;
390 #ifdef CONFIG_ETHERTAP
391 static struct net_device tap0_dev = {
392 .name = "tap0",
393 .base_addr = NETLINK_TAPBASE,
394 .next = NEXT_DEV,
395 .init = ethertap_probe,
397 #undef NEXT_DEV
398 #define NEXT_DEV (&tap0_dev)
399 #endif
401 #ifdef CONFIG_SDLA
402 extern int sdla_init(struct net_device *);
403 static struct net_device sdla0_dev = {
404 .name = "sdla0",
405 .next = NEXT_DEV,
406 .init = sdla_init,
408 #undef NEXT_DEV
409 #define NEXT_DEV (&sdla0_dev)
410 #endif
412 #if defined(CONFIG_LTPC)
413 extern int ltpc_probe(struct net_device *);
414 static struct net_device dev_ltpc = {
415 .name = "lt0",
416 .next = NEXT_DEV,
417 .init = ltpc_probe
419 #undef NEXT_DEV
420 #define NEXT_DEV (&dev_ltpc)
421 #endif /* LTPC */
423 #if defined(CONFIG_COPS)
424 extern int cops_probe(struct net_device *);
425 static struct net_device cops2_dev = {
426 .name = "lt2",
427 .next = NEXT_DEV,
428 .init = cops_probe,
430 static struct net_device cops1_dev = {
431 .name = "lt1",
432 .next = &cops2_dev,
433 .init = cops_probe,
435 static struct net_device cops0_dev = {
436 .name = "lt0",
437 .next = &cops1_dev,
438 .init = cops_probe,
440 #undef NEXT_DEV
441 #define NEXT_DEV (&cops0_dev)
442 #endif /* COPS */
444 static struct net_device eth7_dev = {
445 .name = "eth%d",
446 .next = NEXT_DEV,
447 .init = ethif_probe,
449 static struct net_device eth6_dev = {
450 .name = "eth%d",
451 .next = &eth7_dev,
452 .init = ethif_probe,
454 static struct net_device eth5_dev = {
455 .name = "eth%d",
456 .next = &eth6_dev,
457 .init = ethif_probe,
459 static struct net_device eth4_dev = {
460 .name = "eth%d",
461 .next = &eth5_dev,
462 .init = ethif_probe,
464 static struct net_device eth3_dev = {
465 .name = "eth%d",
466 .next = &eth4_dev,
467 .init = ethif_probe,
469 static struct net_device eth2_dev = {
470 .name = "eth%d",
471 .next = &eth3_dev,
472 .init = ethif_probe,
474 static struct net_device eth1_dev = {
475 .name = "eth%d",
476 .next = &eth2_dev,
477 .init = ethif_probe,
479 static struct net_device eth0_dev = {
480 .name = "eth%d",
481 .next = &eth1_dev,
482 .init = ethif_probe,
485 #undef NEXT_DEV
486 #define NEXT_DEV (&eth0_dev)
490 #ifdef CONFIG_TR
491 /* Token-ring device probe */
492 extern int ibmtr_probe(struct net_device *);
493 extern int sk_isa_probe(struct net_device *);
494 extern int proteon_probe(struct net_device *);
495 extern int smctr_probe(struct net_device *);
497 static int
498 trif_probe(struct net_device *dev)
500 if (1
501 #ifdef CONFIG_IBMTR
502 && ibmtr_probe(dev)
503 #endif
504 #ifdef CONFIG_SKISA
505 && sk_isa_probe(dev)
506 #endif
507 #ifdef CONFIG_PROTEON
508 && proteon_probe(dev)
509 #endif
510 #ifdef CONFIG_SMCTR
511 && smctr_probe(dev)
512 #endif
513 && 1 ) {
514 return 1; /* -ENODEV or -EAGAIN would be more accurate. */
516 return 0;
518 static struct net_device tr7_dev = {
519 .name = "tr%d",
520 .next = NEXT_DEV,
521 .init = trif_probe,
523 static struct net_device tr6_dev = {
524 .name = "tr%d",
525 .next = &tr7_dev,
526 .init = trif_probe,
528 static struct net_device tr5_dev = {
529 .name = "tr%d",
530 .next = &tr6_dev,
531 .init = trif_probe,
533 static struct net_device tr4_dev = {
534 .name = "tr%d",
535 .next = &tr5_dev,
536 .init = trif_probe,
538 static struct net_device tr3_dev = {
539 .name = "tr%d",
540 .next = &tr4_dev,
541 .init = trif_probe,
543 static struct net_device tr2_dev = {
544 .name = "tr%d",
545 .next = &tr3_dev,
546 .init = trif_probe,
548 static struct net_device tr1_dev = {
549 .name = "tr%d",
550 .next = &tr2_dev,
551 .init = trif_probe,
553 static struct net_device tr0_dev = {
554 .name = "tr%d",
555 .next = &tr1_dev,
556 .init = trif_probe,
558 #undef NEXT_DEV
559 #define NEXT_DEV (&tr0_dev)
561 #endif
563 #ifdef CONFIG_SBNI
564 static struct net_device sbni7_dev = {
565 .name = "sbni7",
566 .next = NEXT_DEV,
567 .init = sbni_probe,
569 static struct net_device sbni6_dev = {
570 .name = "sbni6",
571 .next = &sbni7_dev,
572 .init = sbni_probe,
574 static struct net_device sbni5_dev = {
575 .name = "sbni5",
576 .next = &sbni6_dev,
577 .init = sbni_probe,
579 static struct net_device sbni4_dev = {
580 .name = "sbni4",
581 .next = &sbni5_dev,
582 .init = sbni_probe,
584 static struct net_device sbni3_dev = {
585 .name = "sbni3",
586 .next = &sbni4_dev,
587 .init = sbni_probe,
589 static struct net_device sbni2_dev = {
590 .name = "sbni2",
591 .next = &sbni3_dev,
592 .init = sbni_probe,
594 static struct net_device sbni1_dev = {
595 .name = "sbni1",
596 .next = &sbni2_dev,
597 .init = sbni_probe,
599 static struct net_device sbni0_dev = {
600 .name = "sbni0",
601 .next = &sbni1_dev,
602 .init = sbni_probe,
605 #undef NEXT_DEV
606 #define NEXT_DEV (&sbni0_dev)
607 #endif
610 * The loopback device is global so it can be directly referenced
611 * by the network code. Also, it must be first on device list.
614 extern int loopback_init(struct net_device *dev);
615 struct net_device loopback_dev = {
616 .name = "lo",
617 .next = NEXT_DEV,
618 .init = loopback_init
622 * The @dev_base list is protected by @dev_base_lock and the rtln
623 * semaphore.
625 * Pure readers hold dev_base_lock for reading.
627 * Writers must hold the rtnl semaphore while they loop through the
628 * dev_base list, and hold dev_base_lock for writing when they do the
629 * actual updates. This allows pure readers to access the list even
630 * while a writer is preparing to update it.
632 * To put it another way, dev_base_lock is held for writing only to
633 * protect against pure readers; the rtnl semaphore provides the
634 * protection against other writers.
636 * See, for example usages, register_netdevice() and
637 * unregister_netdevice(), which must be called with the rtnl
638 * semaphore held.
640 struct net_device *dev_base = &loopback_dev;
641 rwlock_t dev_base_lock = RW_LOCK_UNLOCKED;