Old Interface Between Device Drivers and Kernel: First Part of netif_rx
The netif_rx function, defined in
net/core/dev.c, is normally called by device drivers when new input
frames are waiting to be processed;[*] its job is to schedule the softirq that runs shortly to dequeue and handle the
frames. Figure 10-3 shows what it checks
for and the flow of its events. The figure is practically longer than the code, but it is
useful to help understand how netif_rx reacts to its
context.
netif_rx is usually called by a driver while in
interrupt context, but there are exceptions, notably when the function is called by the
loopback device. For this reason, netif_rx disables
interrupts on the local CPU when it starts, and re-enables them when it finishes.[†]
When looking at the code, one should keep in mind that different CPUs can run netif_rx concurrently. This is not a problem, since each CPU
is associated with a private softnet_data structure
that maintains state information. Among other things, the CPU's softnet_data structure includes a private input queue (see the section "softnet_data Structure" in Chapter 9).

Figure 10-3. netif_rx function
This is the function's prototype:
int netif_rx(struct sk_buff *skb)
Its only input parameter is the buffer received by the device, and the output value is an indication of the congestion level (you can find details in the section "Congestion Management
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access