network driver tx/rx path buffers

Tobin C. Harding me at tobin.cc
Tue Jun 13 19:57:41 EDT 2017


Hi,

I am implementing the rx/tx paths for a network driver.

My current understanding is;

On the tx path the driver processes the sk_buff, producing a
frame, and writes this to the tx buffer.

At interrupt time (given that the device produces interrupts for rx
data received and tx data transmitted) the driver either fills the rx
buffer with the received frame read from the device or empties the tx
buffer and writes the frame to the device.

Once rx data has been written to the buffer the driver should empty the rx
buffer, process the frame and pass it upstairs.

Questions
---------

1. Is it ok to process the rx frame in a tasklet or should the tasklet
schedule a work thread to do it so that we are not in software
interrupt context for the entire processing of the frame?

2. Can you us kfifo.h for varying size discreet chunks of data? The
macros in kfifo.h are quite complex for a kernelnewbie, but it seems
that kfifo is better suited to storing fixed size items (i.e stucts)?

3. If the above buffer handling is correct then the data being written
to the rx and tx buffers is of varying size. Is circ_buf.h combined with 
buffer in the device data structure a better option?


For reference, paraphrasing LDD3:

For interrupt driven I/O the input buffer should be filled at
interrupt time and emptied by processes that read the device; the
output buffer should be filled by processes that write to the device
and emptied at interrupt time.

thanks,
Tobin.



More information about the Kernelnewbies mailing list