New API: Difference between revisions

Content deleted Content added
+ Template:Linux, this template should be slit into Template:Linux kernel and Template:Linux OS family
Cleanup of section titles
Line 3:
{{primary sources|date=April 2013}}
}}
 
'''New API''' (also referred to as '''NAPI''') is an interface to use [[interrupt mitigation]] techniques for networking devices in the [[Linux kernel]].
Such an approach is intended to reduce the overhead of packet receiving. The idea is to defer incoming message handling until there is a sufficient amount of them so that it is worth handling them all at once.
 
==Motivation==
==Motivations for using NAPI==
 
A straightforward method of implementing a network driver is to interrupt the kernel by issuing an [[interrupt request]] (IRQ) for each and every incoming packet. However, servicing IRQs is costly in terms of processor resources and time. Therefore the straightforward implementation can be very inefficient in high-speed networks, constantly interrupting the kernel with the thousands of packets per second. Overall performance of the system as well as network throughput can suffer as a result.
 
Line 14:
As a compromise, the Linux kernel uses the interrupt-driven mode by default and only switches to polling mode when the flow of incoming packets exceeds a certain threshold, known as the "weight" of the network interface.
 
==NAPI compliantCompliant drivers==
A driver using the '''NAPI''' interface will work as follow :
* Packet receive interrupts are disabled.
Line 20:
* When allowed to, the kernel calls the device poll method to possibly handle many packets at once.
 
==Advantages of using NAPI==
* The load induced by [[interrupt request|interrupts]] is reduced even though the kernel has to poll.
* Packets are less likely to be re-ordered, while out of order packet handling might be a bottleneck otherwise.
* In case the kernel is unable to handle all incoming packets, the kernel does not have to do any work in order to drop them: they are simply overwritten in the [[network card]]'s incoming [[ring buffer]]. Without NAPI, the kernel has to handle every incoming packet regardless of whether there is time to service it, which leads to [[thrashing (computer science)|thrashing]].
 
==History of NAPI==
NAPI was an over three year effort by Alexey Kuznetsov, Jamal Hadi Salim and Robert Olsson.
Initial effort to include NAPI was met with resistance by some members of the community, however