What needs to be done so that Linux can run two ethernet cards?

What needs to be done so that Linux can run two ethernet cards?

Using More than one Ethernet Card per Machine

The answer to this question depends on whether the driver(s) is/are being used as a loadable module or are compiled directly into the kernel. Most linux distributions use modular drivers now. This saves distributing lots of kernels, each with a different driver set built in. Instead a single basic kernel is used and the individual drivers that are need for a particular user's system are loaded once the system has booted far enough to access the driver module files (usually stored in /lib/modules/).

With the Driver as a Module: In the case of PCI drivers, the module will typically detect all of the installed cards of that brand model automatically. However, for ISA cards, probing for a card is not a safe operation, and hence you typically need to supply the I/O base address of the card so the module knows where to look. This information is stored in the file /etc/conf.modules.

As an example, consider a user that has two ISA NE2000 cards, one at 0x300 and one at 0x240 and what lines they would have in their /etc/conf.modules file:

        alias eth0 ne
alias eth1 ne
options ne io=0x240,0x300

What this does: This says that if the administrator (or the kernel) does a modprobe eth0 or a modprobe eth1 then the ne.o driver should be loaded for either eth0 or eth1. Furthermore, when the ne.o module is loaded, it should be loaded with the options io=0x240,0x300 so that the driver knows where to look for the cards. Note that the 0x is important - things like 300h as commonly used in the DOS world won't work. Switching the order of the 0x240 and the 0x300 will switch which physical card ends up as eth0 and eth1.

Most of the ISA module drivers can take multiple comma separated I/O values like this example to handle multiple cards. However, some (older?) drivers, such as the 3c501.o module are currently only able to handle one card per module load. In this case you can load the module twice to get both cards detected. The /etc/conf.modules file in this case would look like:

        alias eth0 3c501
alias eth1 3c501
options eth0 -o 3c501-0 io=0x280 irq=5
options eth1 -o 3c501-1 io=0x300 irq=7

In this example the -o option has been used to give each instance of the module a unique name, since you can't have two modules loaded with the same name. The irq= option has also been used to to specify the hardware IRQ setting of the card. (This method can also be used with modules that accept comma separated I/O values, but it is less efficient since the module ends up being loaded twice when it doesn't really need to be.)

As a final example, consider a user with one 3c503 card at 0x350 and one SMC Elite16 (wd8013) card at 0x280. They would have:

        alias eth0 wd
alias eth1 3c503
options wd io=0x280
options 3c503 io=0x350

For PCI cards, you typically only need the alias lines to correlate the ethN interfaces with the appropriate driver name, since the I/O base of a PCI card can be safely detected.

The available modules are typically stored in /lib/modules/`uname -r`/net where the uname -r command gives the kernel version (e.g. 2.0.34). You can look in there to see which one matches your card. Once you have the correct settings in your conf.modules file, you can test things out with:

        modprobe ethN
dmesg | tail

where `N' is the number of the ethernet interface you are testing.

With the Driver Compiled into the Kernel: If you have the driver compiled into the kernel, then the hooks for multiple ethercards are all there. However, note that at the moment only one ethercard is auto-probed for by default. This helps to avoid possible boot time hangs caused by probing sensitive cards.

(Note: As of late 2.1.x kernels, the boot probes have been sorted into safe and unsafe, so that all safe (e.g. PCI and EISA) probes will find all related cards automatically. Systems with more than one ethernet card with at least one of them being an ISA card will still need to do one of the following.)

There are two ways that you can enable auto-probing for the second (and third, and...) card. The easiest method is to pass boot-time arguments to the kernel, which is usually done by LILO. Probing for the second card can be achieved by using a boot-time argument as simple as ether=0,0,eth1. In this case eth0 and eth1 will be assigned in the order that the cards are found at boot. Say if you want the card at 0x300 to be eth0 and the card at 0x280 to be eth1 then you could use

LILO: linux ether=5,0x300,eth0 ether=15,0x280,eth1

The ether= command accepts more than the IRQ + I/O + name shown above. Please have a look at Passing Ethernet Arguments... for the full syntax, card specific parameters, and LILO tips.

These boot time arguments can be made permanent so that you don't have to re-enter them every time. See the LILO configuration option `append' in the LILO manual.

The second way (not recommended) is to edit the file Space.c and replace the 0xffe0 entry for the I/O address with a zero. The 0xffe0 entry tells it not to probe for that device -- replacing it with a zero will enable autoprobing for that device.

No comments:

Post a Comment