SnabbCo/snabbswitch — pull request #38 by pkazmier (2013-01-14 21:00:21+00:00)
Title: Change to let me work on 82571 driver without clashing with your 82574 driver.

As I start to work on the driver for the Intel 82571, I wanted
an easy way to allow for the coexistence of multiple Ethernet
drivers (LUA modules). Here is a summary of the changes:

1. We register the name of a driver module that can support a given
PCI vendor / device ID combination via `pci.register()`. These are
registered in `main.lua` for the time being.

2. When searching for suitable devices, instead of hardcoding the
Intel 82574 device ID, the PCI module will search for any hardware
for which a driver has been registered with the vendor / device ID.

3. To instantiate a driver, you no longer call `intel.new()`, but
rather `pci.driver(pciaddress)`, which will load the module and
return an instance of the driver for your hardware if one
exists. The file `selftest.lua` has been modified to load the
driver in this manner.

4. I added a property to the driver object called `M.driver_name`,
which is used for printing the name of the driver that was
loaded. It's to give us assurance that this code is loading the
right driver.
```
...
selftest: intel device 0000:01:00.0
Loaded the Intel 82571 driver
NIC transmit test
...
```

5. For testing purposes, I added the `intel_82571.lua` module which is
an exact copy of `intel.lua`. The only difference, for now, is that
the `M.driver_name` correctly identifies itself as an 82571
driver.

In summary, this commit allows me to hack away at `intel_82571.lua`
without stepping on your toes :-)