<s>
New	B-Architecture
API	I-Architecture
(	O
also	O
referred	O
to	O
as	O
NAPI	B-Architecture
)	O
is	O
an	O
interface	O
to	O
use	O
interrupt	B-General_Concept
mitigation	I-General_Concept
techniques	O
for	O
networking	O
devices	O
in	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
A	O
straightforward	O
method	O
of	O
implementing	O
a	O
network	O
driver	O
is	O
to	O
interrupt	O
the	O
kernel	B-Operating_System
by	O
issuing	O
an	O
interrupt	B-General_Concept
request	I-General_Concept
(	O
IRQ	B-General_Concept
)	O
for	O
each	O
and	O
every	O
incoming	O
packet	O
.	O
</s>
<s>
However	O
,	O
servicing	O
IRQs	B-General_Concept
is	O
costly	O
in	O
terms	O
of	O
processor	O
resources	O
and	O
time	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
straightforward	O
implementation	O
can	O
be	O
very	O
inefficient	O
in	O
high-speed	O
networks	O
,	O
constantly	O
interrupting	O
the	O
kernel	B-Operating_System
with	O
the	O
thousands	O
of	O
packets	O
per	O
second	O
.	O
</s>
<s>
Polling	B-General_Concept
is	O
an	O
alternative	O
to	O
interrupt-based	O
processing	O
.	O
</s>
<s>
The	O
kernel	B-Operating_System
can	O
periodically	O
check	O
for	O
the	O
arrival	O
of	O
incoming	O
network	O
packets	O
without	O
being	O
interrupted	O
,	O
which	O
eliminates	O
the	O
overhead	O
of	O
interrupt	O
processing	O
.	O
</s>
<s>
Establishing	O
an	O
optimal	O
polling	B-General_Concept
frequency	I-General_Concept
is	O
important	O
,	O
however	O
.	O
</s>
<s>
Too	O
frequent	O
polling	B-General_Concept
wastes	O
CPU	O
resources	O
by	O
repeatedly	O
checking	O
for	O
incoming	O
packets	O
that	O
have	O
not	O
yet	O
arrived	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
polling	B-General_Concept
too	O
infrequently	O
introduces	O
latency	O
by	O
reducing	O
system	O
reactivity	O
to	O
incoming	O
packets	O
,	O
and	O
it	O
may	O
result	O
in	O
the	O
loss	O
of	O
packets	O
if	O
the	O
incoming	O
packet	O
buffer	O
fills	O
up	O
before	O
being	O
processed	O
.	O
</s>
<s>
As	O
a	O
compromise	O
,	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
uses	O
the	O
interrupt-driven	O
mode	O
by	O
default	O
and	O
only	O
switches	O
to	O
polling	B-General_Concept
mode	O
when	O
the	O
flow	O
of	O
incoming	O
packets	O
exceeds	O
a	O
certain	O
threshold	O
,	O
known	O
as	O
the	O
"	O
weight	O
"	O
of	O
the	O
network	O
interface	O
.	O
</s>
<s>
A	O
driver	O
using	O
the	O
NAPI	B-Architecture
interface	O
will	O
work	O
as	O
follow	O
:	O
</s>
<s>
Packet	O
receive	O
interrupts	B-General_Concept
are	O
disabled	O
.	O
</s>
<s>
The	O
driver	O
provides	O
a	O
poll	O
method	O
to	O
the	O
kernel	B-Operating_System
.	O
</s>
<s>
That	O
method	O
will	O
fetch	O
all	O
incoming	O
packets	O
available	O
,	O
on	O
the	O
network	B-Protocol
card	I-Protocol
or	O
a	O
DMA	B-General_Concept
ring	O
,	O
so	O
that	O
they	O
will	O
then	O
be	O
handled	O
by	O
the	O
kernel	B-Operating_System
.	O
</s>
<s>
When	O
allowed	O
to	O
,	O
the	O
kernel	B-Operating_System
calls	O
the	O
device	O
poll	O
method	O
to	O
possibly	O
handle	O
many	O
packets	O
at	O
once	O
.	O
</s>
<s>
The	O
load	O
induced	O
by	O
interrupts	B-General_Concept
is	O
reduced	O
even	O
though	O
the	O
kernel	B-Operating_System
has	O
to	O
poll	O
.	O
</s>
<s>
In	O
case	O
the	O
kernel	B-Operating_System
is	O
unable	O
to	O
handle	O
all	O
incoming	O
packets	O
,	O
the	O
kernel	B-Operating_System
does	O
not	O
have	O
to	O
do	O
any	O
work	O
in	O
order	O
to	O
drop	O
them	O
:	O
they	O
are	O
simply	O
overwritten	O
in	O
the	O
network	B-Protocol
card	I-Protocol
's	O
incoming	O
ring	B-Data_Structure
buffer	I-Data_Structure
.	O
</s>
<s>
Without	O
NAPI	B-Architecture
,	O
the	O
kernel	B-Operating_System
has	O
to	O
handle	O
every	O
incoming	O
packet	O
regardless	O
of	O
whether	O
there	O
is	O
time	O
to	O
service	O
it	O
,	O
which	O
leads	O
to	O
thrashing	B-General_Concept
.	O
</s>
<s>
NAPI	B-Architecture
was	O
an	O
over-three-year	O
effort	O
by	O
Alexey	O
Kuznetsov	O
,	O
Jamal	O
Hadi	O
Salim	O
and	O
Robert	O
Olsson	O
.	O
</s>
<s>
Initial	O
effort	O
to	O
include	O
NAPI	B-Architecture
was	O
met	O
with	O
resistance	O
by	O
some	O
members	O
of	O
the	O
community	O
,	O
however	O
David	O
Miller	O
worked	O
hard	O
to	O
ensure	O
NAPI	B-Architecture
's	O
inclusion	O
.	O
</s>
<s>
In	O
fact	O
,	O
was	O
the	O
first	O
production	O
NAPI-based	O
OS	O
and	O
is	O
still	O
powered	O
to	O
this	O
day	O
by	O
NAPI-based	O
Bifrost/Linux	O
routers	O
.	O
</s>
<s>
The	O
traffic	B-Protocol
generator	I-Protocol
was	O
also	O
born	O
around	O
this	O
time	O
.	O
</s>
<s>
Pktgen	O
was	O
extensively	O
used	O
to	O
test	O
NAPI	B-Architecture
scenarios	O
not	O
induced	O
by	O
real	O
world	O
traffic	O
.	O
</s>
