Merge pull request #52 from sleinen/clean-up-after-selftest

(intel10g): Restore adapter configuration state after selftest.
virtio.lua: selftest() now runs for 1s instead of 10s by default.

Can now be controlled with `selftest({secs=N})`
selftest function refactoring.

selftest.lua is now tiny and only loads modules and calls their
selftest() function.

main.lua takes on the basic initialization tasks that were done in
selftest.lua e.g. making sure C headers are loaded and available.
main.lua: Load snabb.h definitions in initialization.
memory.lua: Added high-level allocate()/free() interface.

Code borrowed from hub2 selftest.
port.lua: New high-level abstraction for a logical ethernet port.

Ports are the layer above device drivers. Currently driver-independent selftest code is consolidated here. This is also where we can have code that feeds packets into switch objects.

Early days!
intel.lua: Switched from new() function to one-module-per-NIC model.

This commit is extremely noisy because it changes the indentation
level in most of the file. So it will be hard to diff and so I have
kept it minimal:

1. Change module().
2. Unwrap module body from new().

Future commits will make it actually work.
intel.lua: Removed 'M' module dictionary. Functions are not local anymore.
intel.h: Moved FFI data structure defintions here.

These should always be defined exactly once;
intel and intel10g moduels both need them;
both of those modules can be loaded N times.

So better to put them in a simple header file.

Could be handy for C code to see this in the future too.
pci.lua: Bug fix - don't unbind devices from Linux if they are already unbound.
selftest.lua: Don't call port.selftest().

The expectation for now is that:
  selftest.lua calls pci.selftest()
  pci.selftest() finds all devices and calls their selftest()s.
  device (e.g. intel) selftest() calls port.selftest() as a library function.
port.lua: selftest() can now take a device for test as an option.
intel.lua: Updated for new I/O API.

Debugging needed.

Reclaiming transmit buffers not implemented.
buffer.lua: New data structure representing a network buffer.

This is introduced to keep relevant information together in one
place (virtual address, physical address, available size, used size)
and to allow for reference counting.

Partly implemented in the code base: port.lua spam() and intel.lua.

This commit changes the I/O API incompatibly - transmit() and
receive() both expect buffer structs now - so virtio and intel10g
modules need updating.
port.lua: spam() now idle-sleeps and uses smallest possible packets.
intel.lua: Cache RDH and TDH registers.

Reading registers is really, really slow: waiting for a round-trip
over PCIe. Caching registers is the best optimization I have found so
far.
intel10g: Removed reclaim_buffer logic.
Added authorized_keys file.

Contains SSH public key for everybody who would like to use shared
project servers.
Use the 'intel' driver for the Intel 82571 card
Makefile: Statically link jit.* modules from LuaJIT.

Thanks Mike Pall for telling me how to do this.