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 * 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.
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>
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
);
111 extern int sbni_probe(struct net_device
*);
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
;
132 while (p
->probe
!= NULL
) {
133 if (base_addr
&& p
->probe(dev
) == 0) { /* probe given addr */
134 ret
= alloc_divert_blk(dev
);
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
);
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 */
162 #ifdef CONFIG_ULTRA32
181 static struct devprobe mca_probes
[] __initdata
= {
182 #ifdef CONFIG_NE2_MCA
185 #ifdef CONFIG_ELMC /* 3c523 */
188 #ifdef CONFIG_ELMC_II /* 3c527 */
191 #ifdef CONFIG_SKMC /* SKnet Microchannel */
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 */
214 #ifdef CONFIG_EL2 /* 3c503 */
220 #ifdef CONFIG_HPLAN_PLUS
223 #ifdef CONFIG_E2100 /* Cabletron E21xx series. */
226 #if defined(CONFIG_NE2000) || defined(CONFIG_NE2K_CBUS) /* ISA & PC-9800 CBUS (use ne2k-pci for PCI cards) */
229 #ifdef CONFIG_LANCE /* ISA/VLB (use pcnet32 for PCI cards) */
232 #ifdef CONFIG_SMC9194
235 #ifdef CONFIG_SEEQ8005
247 #ifdef CONFIG_FMV18X /* Fujitsu FMV-181/182 */
251 {eth16i_probe
, 0}, /* ICL EtherTeam 16i/32 */
253 #ifdef CONFIG_EEXPRESS /* Intel EtherExpress */
256 #ifdef CONFIG_EEXPRESS_PRO /* Intel EtherExpress Pro/10 */
259 #ifdef CONFIG_DEPCA /* DEC DEPCA */
262 #ifdef CONFIG_EWRK3 /* DEC EtherWORKS 3 */
265 #if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET) /* Intel I82596 */
268 #ifdef CONFIG_EL1 /* 3c501 */
271 #ifdef CONFIG_WAVELAN /* WaveLAN */
274 #ifdef CONFIG_ARLAN /* Aironet */
277 #ifdef CONFIG_EL16 /* 3c507 */
280 #ifdef CONFIG_ELPLUS /* 3c505 */
298 static struct devprobe parport_probes
[] __initdata
= {
299 #ifdef CONFIG_DE620 /* D-Link DE-620 adapter */
305 static struct devprobe m68k_probes
[] __initdata
= {
306 #ifdef CONFIG_ATARILANCE /* Lance-based Atari ethernet boards */
307 {atarilance_probe
, 0},
309 #ifdef CONFIG_SUN3LANCE /* sun3 onboard Lance chip */
310 {sun3lance_probe
, 0},
312 #ifdef CONFIG_SUN3_82586 /* sun3 onboard Intel 82586 chip */
313 {sun3_82586_probe
, 0},
315 #ifdef CONFIG_APNE /* A1200 PCMCIA NE2000 */
318 #ifdef CONFIG_ATARI_BIONET /* Atari Bionet Ethernet board */
321 #ifdef CONFIG_ATARI_PAMSNET /* Atari PAMsNet Ethernet board */
324 #ifdef CONFIG_HPLANCE /* HP300 internal Ethernet */
327 #ifdef CONFIG_MVME147_NET /* MVME147 internal Ethernet */
328 {mvme147lance_probe
, 0},
330 #ifdef CONFIG_MACMACE /* Mac 68k Quadra AV builtin Ethernet */
333 #ifdef CONFIG_MACSONIC /* Mac SONIC-based Ethernet of all sorts */
336 #ifdef CONFIG_MAC8390 /* NuBus NS8390-based cards */
339 #ifdef CONFIG_MAC89x0
345 static struct devprobe mips_probes
[] __initdata
= {
346 #ifdef CONFIG_MIPS_JAZZ_SONIC
349 #ifdef CONFIG_BAGETLANCE /* Lance-based Baget ethernet boards */
350 {bagetlance_probe
, 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
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)
377 if (probe_list(dev
, mips_probes
) == 0)
379 if (probe_list(dev
, eisa_probes
) == 0)
381 if (probe_list(dev
, mca_probes
) == 0)
383 if (probe_list(dev
, isa_probes
) == 0)
385 if (probe_list(dev
, parport_probes
) == 0)
390 #ifdef CONFIG_ETHERTAP
391 static struct net_device tap0_dev
= {
393 .base_addr
= NETLINK_TAPBASE
,
395 .init
= ethertap_probe
,
398 #define NEXT_DEV (&tap0_dev)
402 extern int sdla_init(struct net_device
*);
403 static struct net_device sdla0_dev
= {
409 #define NEXT_DEV (&sdla0_dev)
412 #if defined(CONFIG_LTPC)
413 extern int ltpc_probe(struct net_device
*);
414 static struct net_device dev_ltpc
= {
420 #define NEXT_DEV (&dev_ltpc)
423 #if defined(CONFIG_COPS)
424 extern int cops_probe(struct net_device
*);
425 static struct net_device cops2_dev
= {
430 static struct net_device cops1_dev
= {
435 static struct net_device cops0_dev
= {
441 #define NEXT_DEV (&cops0_dev)
444 static struct net_device eth7_dev
= {
449 static struct net_device eth6_dev
= {
454 static struct net_device eth5_dev
= {
459 static struct net_device eth4_dev
= {
464 static struct net_device eth3_dev
= {
469 static struct net_device eth2_dev
= {
474 static struct net_device eth1_dev
= {
479 static struct net_device eth0_dev
= {
486 #define NEXT_DEV (ð0_dev)
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
*);
498 trif_probe(struct net_device
*dev
)
507 #ifdef CONFIG_PROTEON
508 && proteon_probe(dev
)
514 return 1; /* -ENODEV or -EAGAIN would be more accurate. */
518 static struct net_device tr7_dev
= {
523 static struct net_device tr6_dev
= {
528 static struct net_device tr5_dev
= {
533 static struct net_device tr4_dev
= {
538 static struct net_device tr3_dev
= {
543 static struct net_device tr2_dev
= {
548 static struct net_device tr1_dev
= {
553 static struct net_device tr0_dev
= {
559 #define NEXT_DEV (&tr0_dev)
564 static struct net_device sbni7_dev
= {
569 static struct net_device sbni6_dev
= {
574 static struct net_device sbni5_dev
= {
579 static struct net_device sbni4_dev
= {
584 static struct net_device sbni3_dev
= {
589 static struct net_device sbni2_dev
= {
594 static struct net_device sbni1_dev
= {
599 static struct net_device sbni0_dev
= {
606 #define NEXT_DEV (&sbni0_dev)
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
= {
618 .init
= loopback_init
622 * The @dev_base list is protected by @dev_base_lock and the rtln
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
640 struct net_device
*dev_base
= &loopback_dev
;
641 rwlock_t dev_base_lock
= RW_LOCK_UNLOCKED
;