use safer defaults for hwbuf_len and partially revert cecc4c06d8
use safer defaults for hwbuf_len and partially revert cecc4c06d8

We must make sure that incoming packets will never overflow the netmap
buffers, even when the user is using the offset feature. In the typical
scenario, the netmap buffer is 2KiB and, with an MTU of 1500, there are
~500 bytes available for user offsets.

Unfortunately, some NICs accept incoming packets even when they are
larger then the MTU. This means that the only way to stop DMA from
overflowing the netmap buffers, when offsets are allowed, is to choose
an hardware buffer lenght which is smaller than the netmap buffer
lenght. For most NICs and for 2KiB netmap buffers, this means 1024
bytes, which is unconveniently small.

The current code, due to a regression introduced in commit cecc4c06d8,
will select the small hardware buf size even when offsets are not
in use. The main purpose of this patch is to fix this bug by returning
to the normal behavior for the no-offsets case.

At the same time, the patch pushes the handling of the offset case
to the lower level driver code, so that it can be made NIC-specific
(in future patches).

luigirizzo/netmap,luigirizzo/netmap,luigirizzo/netmap,luigirizzo/netmap,luigirizzo/netmap