World Library  
Flag as Inappropriate
Email this Article

New API

Article Id: WHEBN0005690219
Reproduction Date:

Title: New API  
Author: World Heritage Encyclopedia
Language: English
Subject: Linux kernel, Napi, Kernel same-page merging, Evdev, Debugfs
Collection: Ethernet, Interfaces of the Linux Kernel, Linux Kernel Features
Publisher: World Heritage Encyclopedia
Publication
Date:
 

New API

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.

Contents

  • Motivation 1
  • Compliant drivers 2
  • Advantages 3
  • History 4
  • Further reading 5
  • External links 6

Motivation

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.

Polling is an alternative to interrupt-based processing. The kernel can periodically check for the arrival of incoming network packets without being interrupted, which eliminates the overhead of interrupt processing. Establishing an optimal polling frequency is important, however. Too frequent polling wastes CPU resources by repeatedly checking for incoming packets that have not yet arrived. On the other hand, polling too infrequently introduces latency by reducing system reactivity to incoming packets, and it may result in the loss of packets if the incoming packet buffer fills up before being processed.

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.

Compliant drivers

A driver using the NAPI interface will work as follow:

  • Packet receive interrupts are disabled.
  • The driver provides a poll method to the kernel. That method will fetch all incoming packets available, on the network card or a DMA ring, so that they will then be handled by the kernel.
  • When allowed to, the kernel calls the device poll method to possibly handle many packets at once.

Advantages

  • The load induced by 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.

History

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 David Miller worked hard to ensure NAPI's inclusion.

A lot of real world testing was done in the Uppsala university network before inclusion. In fact, www.slu.se was the first production NAPI-based OS and is still powered to this day by NAPI-based Bifrost/Linux routers. The pktgen traffic generator was also born around this time. Pktgen was extensively used to test NAPI scenarios not induced by real world traffic.

Further reading

  • Jamal Hadi Salim, Robert Olsson, Alexey Kuznetsov (2001-11-10). Beyond softnet (PDF). 5th Annual Linux Showcase & Conference (ALS '01). pp. 165–172. Retrieved 2011-03-06.  The classical NAPI paper.
  • Jonathan Corbet (2003-04-28). "Driver porting: Network drivers".  
  • Jonathan Corbet (2006-12-18). "Reworking NAPI".  
  • Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman (February 2005). "Chapter 17: Networking drivers" (PDF). Linux Device Drivers (3rd ed.). O'Reilly Media.  

External links

  • Early NAPI work
  • NAPI description on Linux Foundation
  • Network overview by Rami Rosen // The Linux Foundation
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.