Packet Transmission
The most important tasks performed by network interfaces are data transmission and reception. We’ll start with transmission because it is slightly easier to understand.
Whenever the kernel needs to transmit a data packet, it calls the
hard_start_transmit method to put the data on an
outgoing queue. Each packet handled by the kernel is contained in a
socket buffer structure (struct sk_buff), whose
definition is found in <linux/skbuff.h>. The
structure gets its name from the Unix abstraction used to represent a
network connection, the socket. Even if the
interface has nothing to do with sockets, each network packet belongs
to a socket in the higher network layers, and the input/output buffers
of any socket are lists of struct sk_buff
structures. The same sk_buff structure is used to
host network data throughout all the Linux network subsystems, but a
socket buffer is just a packet as far as the interface is concerned.
A pointer to sk_buff is usually called
skb, and we follow this practice both in the sample
code and in the text.
The socket buffer is a complex structure, and the kernel offers a
number of functions to act on it. The functions are described later in
Section 14.9; for now a few basic facts about
sk_buff are enough for us to write a working
driver.
The socket buffer passed to hard_start_xmit contains the physical packet as it should appear on the media, complete with the transmission-level headers. The interface doesn’t need to modify ...