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>
15 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 09/1999
16 * - fix sbni: s/device/net_device/
17 * Paul Gortmaker (06/98):
18 * - sort probes in a sane way, make sure all (safe) probes
19 * get run once & failed autoprobes don't autoprobe again.
22 * Phase out placeholder dev entries put in the linked list
23 * here in favour of drivers using init_etherdev(NULL, ...)
24 * combined with a single find_all_devs() function (for 2.3)
26 * This program is free software; you can redistribute it and/or
27 * modify it under the terms of the GNU General Public License
28 * as published by the Free Software Foundation; either version
29 * 2 of the License, or (at your option) any later version.
31 #include <linux/config.h>
32 #include <linux/netdevice.h>
33 #include <linux/errno.h>
34 #include <linux/init.h>
35 #include <linux/netlink.h>
36 #include <linux/divert.h>
41 /* A unified ethernet device probe. This is the easiest way to have every
42 ethernet adaptor have the name "eth[0123...]".
45 extern int ne2_probe(struct net_device *dev);
46 extern int hp100_probe(struct net_device *dev);
47 extern int ultra_probe(struct net_device *dev);
48 extern int ultra32_probe(struct net_device *dev);
49 extern int ultramca_probe(struct net_device *dev);
50 extern int wd_probe(struct net_device *dev);
51 extern int el2_probe(struct net_device *dev);
52 extern int ne_probe(struct net_device *dev);
53 extern int hp_probe(struct net_device *dev);
54 extern int hp_plus_probe(struct net_device *dev);
55 extern int znet_probe(struct net_device *);
56 extern int express_probe(struct net_device *);
57 extern int eepro_probe(struct net_device *);
58 extern int el3_probe(struct net_device *);
59 extern int at1500_probe(struct net_device *);
60 extern int at1700_probe(struct net_device *);
61 extern int fmv18x_probe(struct net_device *);
62 extern int eth16i_probe(struct net_device *);
63 extern int depca_probe(struct net_device *);
64 extern int i82596_probe(struct net_device *);
65 extern int ewrk3_probe(struct net_device *);
66 extern int de4x5_probe(struct net_device *);
67 extern int el1_probe(struct net_device *);
68 extern int wavelan_probe(struct net_device *);
69 extern int arlan_probe(struct net_device *);
70 extern int el16_probe(struct net_device *);
71 extern int elmc_probe(struct net_device *);
72 extern int skmca_probe(struct net_device *);
73 extern int elplus_probe(struct net_device *);
74 extern int ac3200_probe(struct net_device *);
75 extern int es_probe(struct net_device *);
76 extern int lne390_probe(struct net_device *);
77 extern int ne3210_probe(struct net_device *);
78 extern int e2100_probe(struct net_device *);
79 extern int ni5010_probe(struct net_device *);
80 extern int ni52_probe(struct net_device *);
81 extern int ni65_probe(struct net_device *);
82 extern int sonic_probe(struct net_device *);
83 extern int SK_init(struct net_device *);
84 extern int seeq8005_probe(struct net_device *);
85 extern int smc_init( struct net_device * );
86 extern int sgiseeq_probe(struct net_device *);
87 extern int atarilance_probe(struct net_device *);
88 extern int sun3lance_probe(struct net_device *);
89 extern int sun3_82586_probe(struct net_device *);
90 extern int apne_probe(struct net_device *);
91 extern int bionet_probe(struct net_device *);
92 extern int pamsnet_probe(struct net_device *);
93 extern int cs89x0_probe(struct net_device *dev);
94 extern int ethertap_probe(struct net_device *dev);
95 extern int hplance_probe(struct net_device *dev);
96 extern int bagetlance_probe(struct net_device *);
97 extern int mvme147lance_probe(struct net_device *dev);
98 extern int tc515_probe(struct net_device *dev);
99 extern int lance_probe(struct net_device *dev);
100 extern int mace_probe(struct net_device *dev);
101 extern int macsonic_probe(struct net_device *dev);
102 extern int mac8390_probe(struct net_device *dev);
103 extern int mac89x0_probe(struct net_device *dev);
104 extern int mc32_probe(struct net_device *dev);
106 /* Detachable devices ("pocket adaptors") */
107 extern int de600_probe(struct net_device *);
108 extern int de620_probe(struct net_device *);
111 extern int skfp_probe(struct net_device *dev);
113 /* Fibre Channel adapters */
114 extern int iph5526_probe(struct net_device *dev);
117 extern int sbni_probe(struct net_device *);
121 int (*probe)(struct net_device *dev);
122 int status; /* non-zero if autoprobe has failed */
126 * probe_list walks a list of probe functions and calls each so long
127 * as a non-zero ioaddr is given, or as long as it hasn't already failed
128 * to find a card in the past (as recorded by "status") when asked to
129 * autoprobe (i.e. a probe that fails to find a card when autoprobing
130 * will not be asked to autoprobe again). It exits when a card is found.
132 static int __init probe_list(struct net_device *dev, struct devprobe *plist)
134 struct devprobe *p = plist;
135 unsigned long base_addr = dev->base_addr;
136 #ifdef CONFIG_NET_DIVERT
138 #endif /* CONFIG_NET_DIVERT */
140 while (p->probe != NULL) {
141 if (base_addr && p->probe(dev) == 0) { /* probe given addr */
142 #ifdef CONFIG_NET_DIVERT
143 ret = alloc_divert_blk(dev);
146 #endif /* CONFIG_NET_DIVERT */
148 } else if (p->status == 0) { /* has autoprobe failed yet? */
149 p->status = p->probe(dev); /* no, try autoprobe */
150 if (p->status == 0) {
151 #ifdef CONFIG_NET_DIVERT
152 ret = alloc_divert_blk(dev);
155 #endif /* CONFIG_NET_DIVERT */
165 * This is a bit of an artificial separation as there are PCI drivers
166 * that also probe for EISA cards (in the PCI group) and there are ISA
167 * drivers that probe for EISA cards (in the ISA group). These are the
168 * EISA only driver probes, and also the legacy PCI probes
170 static struct devprobe eisa_probes[] __initdata = {
171 #ifdef CONFIG_DE4X5 /* DEC DE425, DE434, DE435 adapters */
174 #ifdef CONFIG_ULTRA32
193 static struct devprobe mca_probes[] __initdata = {
194 #ifdef CONFIG_ULTRAMCA
197 #ifdef CONFIG_NE2_MCA
200 #ifdef CONFIG_ELMC /* 3c523 */
203 #ifdef CONFIG_ELMC_II /* 3c527 */
206 #ifdef CONFIG_SKMC /* SKnet Microchannel */
213 * ISA probes that touch addresses < 0x400 (including those that also
214 * look for EISA/PCI/MCA cards in addition to ISA cards).
216 static struct devprobe isa_probes[] __initdata = {
217 #ifdef CONFIG_EL3 /* ISA, EISA, MCA 3c5x9 */
220 #ifdef CONFIG_HP100 /* ISA, EISA & PCI */
232 #ifdef CONFIG_EL2 /* 3c503 */
238 #ifdef CONFIG_HPLAN_PLUS
241 #ifdef CONFIG_E2100 /* Cabletron E21xx series. */
244 #ifdef CONFIG_NE2000 /* ISA (use ne2k-pci for PCI cards) */
247 #ifdef CONFIG_LANCE /* ISA/VLB (use pcnet32 for PCI cards) */
250 #ifdef CONFIG_SMC9194
253 #ifdef CONFIG_SEEQ8005
265 #ifdef CONFIG_FMV18X /* Fujitsu FMV-181/182 */
269 {eth16i_probe, 0}, /* ICL EtherTeam 16i/32 */
271 #ifdef CONFIG_ZNET /* Zenith Z-Note and some IBM Thinkpads. */
274 #ifdef CONFIG_EEXPRESS /* Intel EtherExpress */
277 #ifdef CONFIG_EEXPRESS_PRO /* Intel EtherExpress Pro/10 */
280 #ifdef CONFIG_DEPCA /* DEC DEPCA */
283 #ifdef CONFIG_EWRK3 /* DEC EtherWORKS 3 */
286 #if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET) /* Intel I82596 */
289 #ifdef CONFIG_EL1 /* 3c501 */
292 #ifdef CONFIG_WAVELAN /* WaveLAN */
295 #ifdef CONFIG_ARLAN /* Aironet */
298 #ifdef CONFIG_EL16 /* 3c507 */
301 #ifdef CONFIG_ELPLUS /* 3c505 */
319 static struct devprobe parport_probes[] __initdata = {
320 #ifdef CONFIG_DE600 /* D-Link DE-600 adapter */
323 #ifdef CONFIG_DE620 /* D-Link DE-620 adapter */
329 static struct devprobe m68k_probes[] __initdata = {
330 #ifdef CONFIG_ATARILANCE /* Lance-based Atari ethernet boards */
331 {atarilance_probe, 0},
333 #ifdef CONFIG_SUN3LANCE /* sun3 onboard Lance chip */
334 {sun3lance_probe, 0},
336 #ifdef CONFIG_SUN3_82586 /* sun3 onboard Intel 82586 chip */
337 {sun3_82586_probe, 0},
339 #ifdef CONFIG_APNE /* A1200 PCMCIA NE2000 */
342 #ifdef CONFIG_ATARI_BIONET /* Atari Bionet Ethernet board */
345 #ifdef CONFIG_ATARI_PAMSNET /* Atari PAMsNet Ethernet board */
348 #ifdef CONFIG_HPLANCE /* HP300 internal Ethernet */
351 #ifdef CONFIG_MVME147_NET /* MVME147 internal Ethernet */
352 {mvme147lance_probe, 0},
354 #ifdef CONFIG_MACMACE /* Mac 68k Quadra AV builtin Ethernet */
357 #ifdef CONFIG_MACSONIC /* Mac SONIC-based Ethernet of all sorts */
360 #ifdef CONFIG_MAC8390 /* NuBus NS8390-based cards */
363 #ifdef CONFIG_MAC89x0
370 static struct devprobe sgi_probes[] __initdata = {
371 #ifdef CONFIG_SGISEEQ
377 static struct devprobe mips_probes[] __initdata = {
378 #ifdef CONFIG_MIPS_JAZZ_SONIC
381 #ifdef CONFIG_BAGETLANCE /* Lance-based Baget ethernet boards */
382 {bagetlance_probe, 0},
388 * Unified ethernet device probe, segmented per architecture and
389 * per bus interface. This drives the legacy devices only for now.
392 static int __init ethif_probe(struct net_device *dev)
394 unsigned long base_addr = dev->base_addr;
397 * Backwards compatibility - historically an I/O base of 1 was
398 * used to indicate not to probe for this ethN interface
401 return 1; /* ENXIO */
404 * The arch specific probes are 1st so that any on-board ethernet
405 * will be probed before other ISA/EISA/MCA/PCI bus cards.
407 if (probe_list(dev, m68k_probes) == 0)
409 if (probe_list(dev, mips_probes) == 0)
411 if (probe_list(dev, sgi_probes) == 0)
413 if (probe_list(dev, eisa_probes) == 0)
415 if (probe_list(dev, mca_probes) == 0)
418 * Backwards compatibility - an I/O of 0xffe0 was used to indicate
419 * that we shouldn't do a bunch of potentially risky ISA probes
420 * for ethN (N>1). Since the widespread use of modules, *nobody*
421 * compiles a kernel with all the ISA drivers built in anymore,
422 * and so we should delete this check in linux 2.3 - Paul G.
424 if (base_addr != 0xffe0 && probe_list(dev, isa_probes) == 0)
426 if (probe_list(dev, parport_probes) == 0)
432 static int __init fddiif_probe(struct net_device *dev)
434 unsigned long base_addr = dev->base_addr;
437 return 1; /* ENXIO */
447 return 1; /* -ENODEV or -EAGAIN would be more accurate. */
455 static int fcif_probe(struct net_device *dev)
457 if (dev->base_addr == -1)
461 #ifdef CONFIG_IPHASE5526
462 && iph5526_probe(dev)
465 return 1; /* -ENODEV or -EAGAIN would be more accurate. */
469 #endif /* CONFIG_NET_FC */
472 #ifdef CONFIG_ETHERTAP
473 static struct net_device tap0_dev = { "tap0", 0, 0, 0, 0, NETLINK_TAPBASE, 0, 0, 0, 0, NEXT_DEV, ethertap_probe, };
475 # define NEXT_DEV (&tap0_dev)
479 extern int sdla_init(struct net_device *);
480 static struct net_device sdla0_dev = { "sdla0", 0, 0, 0, 0, 0, 0, 0, 0, 0, NEXT_DEV, sdla_init, };
483 # define NEXT_DEV (&sdla0_dev)
486 #if defined(CONFIG_LTPC)
487 extern int ltpc_probe(struct net_device *);
488 static struct net_device dev_ltpc = {
492 0, 0, 0, NEXT_DEV, ltpc_probe };
494 # define NEXT_DEV (&dev_ltpc)
497 #if defined(CONFIG_COPS)
498 extern int cops_probe(struct net_device *);
499 static struct net_device cops2_dev = { "lt2", 0, 0, 0, 0, 0x0, 0, 0, 0, 0, NEXT_DEV, cops_probe };
500 static struct net_device cops1_dev = { "lt1", 0, 0, 0, 0, 0x0, 0, 0, 0, 0, &cops2_dev, cops_probe };
501 static struct net_device cops0_dev = { "lt0", 0, 0, 0, 0, 0x0, 0, 0, 0, 0, &cops1_dev, cops_probe };
503 # define NEXT_DEV (&cops0_dev)
507 /* The first device defaults to I/O base '0', which means autoprobe. */
515 /* "eth0" defaults to autoprobe (== 0), other use a base of 0xffe0 (== -0x20),
516 which means "don't do ISA probes". Distributions don't ship kernels with
517 all ISA drivers compiled in anymore, so its probably no longer an issue. */
519 #define ETH_NOPROBE_ADDR 0xffe0
521 static struct net_device eth7_dev = {
522 "eth%d", 0,0,0,0,ETH_NOPROBE_ADDR /* I/O base*/, 0,0,0,0, NEXT_DEV, ethif_probe };
523 static struct net_device eth6_dev = {
524 "eth%d", 0,0,0,0,ETH_NOPROBE_ADDR /* I/O base*/, 0,0,0,0, ð7_dev, ethif_probe };
525 static struct net_device eth5_dev = {
526 "eth%d", 0,0,0,0,ETH_NOPROBE_ADDR /* I/O base*/, 0,0,0,0, ð6_dev, ethif_probe };
527 static struct net_device eth4_dev = {
528 "eth%d", 0,0,0,0,ETH_NOPROBE_ADDR /* I/O base*/, 0,0,0,0, ð5_dev, ethif_probe };
529 static struct net_device eth3_dev = {
530 "eth%d", 0,0,0,0,ETH_NOPROBE_ADDR /* I/O base*/, 0,0,0,0, ð4_dev, ethif_probe };
531 static struct net_device eth2_dev = {
532 "eth%d", 0,0,0,0,ETH_NOPROBE_ADDR /* I/O base*/, 0,0,0,0, ð3_dev, ethif_probe };
533 static struct net_device eth1_dev = {
534 "eth%d", 0,0,0,0,ETH_NOPROBE_ADDR /* I/O base*/, 0,0,0,0, ð2_dev, ethif_probe };
536 static struct net_device eth0_dev = {
537 "eth%d", 0, 0, 0, 0, ETH0_ADDR, ETH0_IRQ, 0, 0, 0, ð1_dev, ethif_probe };
540 # define NEXT_DEV (ð0_dev)
545 /* Token-ring device probe */
546 extern int ibmtr_probe(struct net_device *);
547 extern int smctr_probe(struct net_device *);
550 trif_probe(struct net_device *dev)
560 return 1; /* -ENODEV or -EAGAIN would be more accurate. */
564 static struct net_device tr7_dev = {
565 "tr%d",0,0,0,0,0,0,0,0,0, NEXT_DEV, trif_probe };
566 static struct net_device tr6_dev = {
567 "tr%d",0,0,0,0,0,0,0,0,0, &tr7_dev, trif_probe };
568 static struct net_device tr5_dev = {
569 "tr%d",0,0,0,0,0,0,0,0,0, &tr6_dev, trif_probe };
570 static struct net_device tr4_dev = {
571 "tr%d",0,0,0,0,0,0,0,0,0, &tr5_dev, trif_probe };
572 static struct net_device tr3_dev = {
573 "tr%d",0,0,0,0,0,0,0,0,0, &tr4_dev, trif_probe };
574 static struct net_device tr2_dev = {
575 "tr%d",0,0,0,0,0,0,0,0,0, &tr3_dev, trif_probe };
576 static struct net_device tr1_dev = {
577 "tr%d",0,0,0,0,0,0,0,0,0, &tr2_dev, trif_probe };
578 static struct net_device tr0_dev = {
579 "tr%d",0,0,0,0,0,0,0,0,0, &tr1_dev, trif_probe };
581 # define NEXT_DEV (&tr0_dev)
586 static struct net_device fddi7_dev =
587 {"fddi7", 0, 0, 0, 0, 0, 0, 0, 0, 0, NEXT_DEV, fddiif_probe};
588 static struct net_device fddi6_dev =
589 {"fddi6", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fddi7_dev, fddiif_probe};
590 static struct net_device fddi5_dev =
591 {"fddi5", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fddi6_dev, fddiif_probe};
592 static struct net_device fddi4_dev =
593 {"fddi4", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fddi5_dev, fddiif_probe};
594 static struct net_device fddi3_dev =
595 {"fddi3", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fddi4_dev, fddiif_probe};
596 static struct net_device fddi2_dev =
597 {"fddi2", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fddi3_dev, fddiif_probe};
598 static struct net_device fddi1_dev =
599 {"fddi1", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fddi2_dev, fddiif_probe};
600 static struct net_device fddi0_dev =
601 {"fddi0", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fddi1_dev, fddiif_probe};
603 #define NEXT_DEV (&fddi0_dev)
608 static struct net_device fc1_dev = {
609 "fc1", 0, 0, 0, 0, 0, 0, 0, 0, 0, NEXT_DEV, fcif_probe};
610 static struct net_device fc0_dev = {
611 "fc0", 0, 0, 0, 0, 0, 0, 0, 0, 0, &fc1_dev, fcif_probe};
613 # define NEXT_DEV (&fc0_dev)
618 static struct net_device sbni7_dev =
619 {"sbni7", 0, 0, 0, 0, 0, 0, 0, 0, 0, NEXT_DEV, sbni_probe};
620 static struct net_device sbni6_dev =
621 {"sbni6", 0, 0, 0, 0, 0, 0, 0, 0, 0, &sbni7_dev, sbni_probe};
622 static struct net_device sbni5_dev =
623 {"sbni5", 0, 0, 0, 0, 0, 0, 0, 0, 0, &sbni6_dev, sbni_probe};
624 static struct net_device sbni4_dev =
625 {"sbni4", 0, 0, 0, 0, 0, 0, 0, 0, 0, &sbni5_dev, sbni_probe};
626 static struct net_device sbni3_dev =
627 {"sbni3", 0, 0, 0, 0, 0, 0, 0, 0, 0, &sbni4_dev, sbni_probe};
628 static struct net_device sbni2_dev =
629 {"sbni2", 0, 0, 0, 0, 0, 0, 0, 0, 0, &sbni3_dev, sbni_probe};
630 static struct net_device sbni1_dev =
631 {"sbni1", 0, 0, 0, 0, 0, 0, 0, 0, 0, &sbni2_dev, sbni_probe};
632 static struct net_device sbni0_dev =
633 {"sbni0", 0, 0, 0, 0, 0, 0, 0, 0, 0, &sbni1_dev, sbni_probe};
636 #define NEXT_DEV (&sbni0_dev)
640 * The loopback device is global so it can be directly referenced
641 * by the network code. Also, it must be first on device list.
644 extern int loopback_init(struct net_device *dev);
645 struct net_device loopback_dev =
646 {"lo", 0, 0, 0, 0, 0, 0, 0, 0, 0, NEXT_DEV, loopback_init};
649 * The @dev_base list is protected by @dev_base_lock and the rtln
652 * Pure readers hold dev_base_lock for reading.
654 * Writers must hold the rtnl semaphore while they loop through the
655 * dev_base list, and hold dev_base_lock for writing when they do the
656 * actual updates. This allows pure readers to access the list even
657 * while a writer is preparing to update it.
659 * To put it another way, dev_base_lock is held for writing only to
660 * protect against pure readers; the rtnl semaphore provides the
661 * protection against other writers.
663 * See, for example usages, register_netdevice() and
664 * unregister_netdevice(), which must be called with the rtnl
667 struct net_device *dev_base = &loopback_dev;
668 rwlock_t dev_base_lock = RW_LOCK_UNLOCKED;