Mellvik / TLVC

Tiny Linux for Vintage Computers
Other
9 stars 0 forks source link

[net] Add bootopts config option netbufs= for net buffers #37

Closed Mellvik closed 9 months ago

Mellvik commented 9 months ago

This PR adds a new directive - netbufs= to the /bootopts file to specify the number of send and receive buffers for ethernet interfaces. For now only the ne2k driver supports this option. The other ethernet drivers will be updated soon. The syntax is

netbufs=2,1

where the 1st number is receive buffers, the 2nd is transmit buffers. The new option is particularly useful for performance testing. If the option is not present, the numbers in the netbufs.h file in the drivers/net directory will be used. The defaults are 2,2:

#define NET_OBUFCNT 2
#define NET_IBUFCNT 2

Zero is allowed and will turn off buffer usage and prevent buffer memory from being allocated. The buffers are allocated from the kernel heap - unless configured otherwise in the netbufs.h file:

/* Buffer configuration for TLVC Ethernet NICs
 *
 * There are 3 buffer strategies:
 * - No buffers: The driver is moving data directly to/from the requester
 *      (via far mem move).
 * - Static buffers: The number of send and receive buffers specified in the
 *      NET_OBUFCNT and NET_IBUFCNT defines are allocated statically at
 *      compile time. The BUFCNT numbers may be 0, in which case the driver
 *      will run as if NO_BUFS was set (except the extra code is compiled in).
 * - Heap allocation: Buffer space is allocated from the kernel heap, which
 *      is slightly different from static allocation in that memory is
 *      allocated only if the network is running. Memory consumption will be
 *      slightly higher because of the headers in the heap allocation.
 *
 * When HEAP allocation is used, the # of buffers may be set in /bootopts via
 * the 'netbufs=' directive. 'netbufs=2,1' means 2 receive buffers, 1 transmit
 * buffer. The kernel will not do sanity checking on the netbufs= numbers,
 * it's entirely possible to make the system unbootable by requesting too many
 * buffers. 2,1 or 2,2 are reasonable choices for regular usage. Again, zero is
 * a valid selection and will turn off buffers entirely.
 * When using heap allocation, a header strucure per buffer is also
 * allocated from the heap, 6 bytes per buffer.
 *
 * AGAIN: zero buffers is always a valid choice - which complicates the driver
 * somewhat but makes benchmarking much more convenient.
 */