xref: /dpdk/doc/guides/prog_guide/overview.rst (revision 48624fd96e7c4a9603e383baa193909fea392232)
1fc1f2750SBernard Iremonger..  BSD LICENSE
2fc1f2750SBernard Iremonger    Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
3fc1f2750SBernard Iremonger    All rights reserved.
4fc1f2750SBernard Iremonger
5fc1f2750SBernard Iremonger    Redistribution and use in source and binary forms, with or without
6fc1f2750SBernard Iremonger    modification, are permitted provided that the following conditions
7fc1f2750SBernard Iremonger    are met:
8fc1f2750SBernard Iremonger
9fc1f2750SBernard Iremonger    * Redistributions of source code must retain the above copyright
10fc1f2750SBernard Iremonger    notice, this list of conditions and the following disclaimer.
11fc1f2750SBernard Iremonger    * Redistributions in binary form must reproduce the above copyright
12fc1f2750SBernard Iremonger    notice, this list of conditions and the following disclaimer in
13fc1f2750SBernard Iremonger    the documentation and/or other materials provided with the
14fc1f2750SBernard Iremonger    distribution.
15fc1f2750SBernard Iremonger    * Neither the name of Intel Corporation nor the names of its
16fc1f2750SBernard Iremonger    contributors may be used to endorse or promote products derived
17fc1f2750SBernard Iremonger    from this software without specific prior written permission.
18fc1f2750SBernard Iremonger
19fc1f2750SBernard Iremonger    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20fc1f2750SBernard Iremonger    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21fc1f2750SBernard Iremonger    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22fc1f2750SBernard Iremonger    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23fc1f2750SBernard Iremonger    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24fc1f2750SBernard Iremonger    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25fc1f2750SBernard Iremonger    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26fc1f2750SBernard Iremonger    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27fc1f2750SBernard Iremonger    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28fc1f2750SBernard Iremonger    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29fc1f2750SBernard Iremonger    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30fc1f2750SBernard Iremonger
31fc1f2750SBernard Iremonger**Part 1: Architecture Overview**
32fc1f2750SBernard Iremonger
33fc1f2750SBernard IremongerOverview
34fc1f2750SBernard Iremonger========
35fc1f2750SBernard Iremonger
36*48624fd9SSiobhan ButlerThis section gives a global overview of the architecture of Data Plane Development Kit (DPDK).
37fc1f2750SBernard Iremonger
38*48624fd9SSiobhan ButlerThe main goal of the DPDK is to provide a simple,
39fc1f2750SBernard Iremongercomplete framework for fast packet processing in data plane applications.
40fc1f2750SBernard IremongerUsers may use the code to understand some of the techniques employed,
41fc1f2750SBernard Iremongerto build upon for prototyping or to add their own protocol stacks.
42*48624fd9SSiobhan ButlerAlternative ecosystem options that use the DPDK are available.
43fc1f2750SBernard Iremonger
44fc1f2750SBernard IremongerThe framework creates a set of libraries for specific environments
45fc1f2750SBernard Iremongerthrough the creation of an Environment Abstraction Layer (EAL),
46fc1f2750SBernard Iremongerwhich may be specific to a mode of the Intel® architecture (32-bit or 64-bit),
47fc1f2750SBernard IremongerLinux* user space compilers or a specific platform.
48fc1f2750SBernard IremongerThese environments are created through the use of make files and configuration files.
49fc1f2750SBernard IremongerOnce the EAL library is created, the user may link with the library to create their own applications.
50fc1f2750SBernard IremongerOther libraries, outside of EAL, including the Hash,
51fc1f2750SBernard IremongerLongest Prefix Match (LPM) and rings libraries are also provided.
52*48624fd9SSiobhan ButlerSample applications are provided to help show the user how to use various features of the DPDK.
53fc1f2750SBernard Iremonger
54*48624fd9SSiobhan ButlerThe DPDK implements a run to completion model for packet processing,
55fc1f2750SBernard Iremongerwhere all resources must be allocated prior to calling Data Plane applications,
56fc1f2750SBernard Iremongerrunning as execution units on logical processing cores.
57fc1f2750SBernard IremongerThe model does not support a scheduler and all devices are accessed by polling.
58fc1f2750SBernard IremongerThe primary reason for not using interrupts is the performance overhead imposed by interrupt processing.
59fc1f2750SBernard Iremonger
60fc1f2750SBernard IremongerIn addition to the run-to-completion model,
61fc1f2750SBernard Iremongera pipeline model may also be used by passing packets or messages between cores via the rings.
62fc1f2750SBernard IremongerThis allows work to be performed in stages and may allow more efficient use of code on cores.
63fc1f2750SBernard Iremonger
64fc1f2750SBernard IremongerDevelopment Environment
65fc1f2750SBernard Iremonger-----------------------
66fc1f2750SBernard Iremonger
67*48624fd9SSiobhan ButlerThe DPDK project installation requires Linux and the associated toolchain,
68fc1f2750SBernard Iremongersuch as one or more compilers, assembler, make utility,
69*48624fd9SSiobhan Butlereditor and various libraries to create the DPDK components and libraries.
70fc1f2750SBernard Iremonger
71fc1f2750SBernard IremongerOnce these libraries are created for the specific environment and architecture,
72fc1f2750SBernard Iremongerthey may then be used to create the user's data plane application.
73fc1f2750SBernard Iremonger
74fc1f2750SBernard IremongerWhen creating applications for the Linux user space, the glibc library is used.
75*48624fd9SSiobhan ButlerFor DPDK applications, two environmental variables (RTE_SDK and RTE_TARGET)
76fc1f2750SBernard Iremongermust be configured before compiling the applications.
77fc1f2750SBernard IremongerThe following are examples of how the variables can be set:
78fc1f2750SBernard Iremonger
79fc1f2750SBernard Iremonger.. code-block:: console
80fc1f2750SBernard Iremonger
81fc1f2750SBernard Iremonger    export RTE_SDK=/home/user/DPDK
82fc1f2750SBernard Iremonger    export RTE_TARGET=x86_64-native-linuxapp-gcc
83fc1f2750SBernard Iremonger
84*48624fd9SSiobhan ButlerSee the *DPDK Getting Started Guide* for information on setting up the development environment.
85fc1f2750SBernard Iremonger
86fc1f2750SBernard IremongerEnvironment Abstraction Layer
87fc1f2750SBernard Iremonger-----------------------------
88fc1f2750SBernard Iremonger
89fc1f2750SBernard IremongerThe Environment Abstraction Layer (EAL) provides a generic interface
90fc1f2750SBernard Iremongerthat hides the environment specifics from the applications and libraries.
91fc1f2750SBernard IremongerThe services provided by the EAL are:
92fc1f2750SBernard Iremonger
93*48624fd9SSiobhan Butler*   DPDK loading and launching
94fc1f2750SBernard Iremonger
95fc1f2750SBernard Iremonger*   Support for multi-process and multi-thread execution types
96fc1f2750SBernard Iremonger
97fc1f2750SBernard Iremonger*   Core affinity/assignment procedures
98fc1f2750SBernard Iremonger
99fc1f2750SBernard Iremonger*   System memory allocation/de-allocation
100fc1f2750SBernard Iremonger
101fc1f2750SBernard Iremonger*   Atomic/lock operations
102fc1f2750SBernard Iremonger
103fc1f2750SBernard Iremonger*   Time reference
104fc1f2750SBernard Iremonger
105fc1f2750SBernard Iremonger*   PCI bus access
106fc1f2750SBernard Iremonger
107fc1f2750SBernard Iremonger*   Trace and debug functions
108fc1f2750SBernard Iremonger
109fc1f2750SBernard Iremonger*   CPU feature identification
110fc1f2750SBernard Iremonger
111fc1f2750SBernard Iremonger*   Interrupt handling
112fc1f2750SBernard Iremonger
113fc1f2750SBernard Iremonger*   Alarm operations
114fc1f2750SBernard Iremonger
115fc1f2750SBernard IremongerThe EAL is fully described in :ref:`Environment Abstraction Layer <Environment_Abstraction_Layer>`.
116fc1f2750SBernard Iremonger
117fc1f2750SBernard IremongerCore Components
118fc1f2750SBernard Iremonger---------------
119fc1f2750SBernard Iremonger
120fc1f2750SBernard IremongerThe *core components* are a set of libraries that provide all the elements needed
121fc1f2750SBernard Iremongerfor high-performance packet processing applications.
122fc1f2750SBernard Iremonger
123fc1f2750SBernard Iremonger.. _pg_figure_1:
124fc1f2750SBernard Iremonger
125fc1f2750SBernard Iremonger**Figure 1. Core Components Architecture**
126fc1f2750SBernard Iremonger
127fc1f2750SBernard Iremonger.. image2_png has been replaced
128fc1f2750SBernard Iremonger
129fc1f2750SBernard Iremonger|architecture-overview|
130fc1f2750SBernard Iremonger
131fc1f2750SBernard IremongerMemory Manager (librte_malloc)
132fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133fc1f2750SBernard Iremonger
134fc1f2750SBernard IremongerThe librte_malloc library provides an API to allocate memory from the memzones created from the hugepages instead of the heap.
135fc1f2750SBernard IremongerThis helps when allocating large numbers of items that may become susceptible to TLB misses
136fc1f2750SBernard Iremongerwhen using typical 4k heap pages in the Linux user space environment.
137fc1f2750SBernard Iremonger
138fc1f2750SBernard IremongerThis memory allocator is fully described in :ref:`Malloc Library <Malloc_Library>`.
139fc1f2750SBernard Iremonger
140fc1f2750SBernard IremongerRing Manager (librte_ring)
141fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~
142fc1f2750SBernard Iremonger
143fc1f2750SBernard IremongerThe ring structure provides a lockless multi-producer, multi-consumer FIFO API in a finite size table.
144fc1f2750SBernard IremongerIt has some advantages over lockless queues; easier to implement, adapted to bulk operations and faster.
145fc1f2750SBernard IremongerA ring is used by the :ref:`Memory Pool Manager (librte_mempool) <Mempool_Library>`
146fc1f2750SBernard Iremongerand may be used as a general communication mechanism between cores
147fc1f2750SBernard Iremongerand/or execution blocks connected together on a logical core.
148fc1f2750SBernard Iremonger
149fc1f2750SBernard IremongerThis ring buffer and its usage are fully described in :ref:`Ring Library <Ring_Library>`.
150fc1f2750SBernard Iremonger
151fc1f2750SBernard IremongerMemory Pool Manager (librte_mempool)
152fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153fc1f2750SBernard Iremonger
154fc1f2750SBernard IremongerThe Memory Pool Manager is responsible for allocating pools of objects in memory.
155fc1f2750SBernard IremongerA pool is identified by name and uses a ring to store free objects.
156fc1f2750SBernard IremongerIt provides some other optional services,
157fc1f2750SBernard Iremongersuch as a per-core object cache and an alignment helper to ensure that objects are padded to spread them equally on all RAM channels.
158fc1f2750SBernard Iremonger
159fc1f2750SBernard IremongerThis memory pool allocator is described in  :ref:`Mempool Library <Mempool_Library>`.
160fc1f2750SBernard Iremonger
161fc1f2750SBernard IremongerNetwork Packet Buffer Management (librte_mbuf)
162fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163fc1f2750SBernard Iremonger
164fc1f2750SBernard IremongerThe mbuf library provides the facility to create and destroy buffers
165*48624fd9SSiobhan Butlerthat may be used by the DPDK application to store message buffers.
166*48624fd9SSiobhan ButlerThe message buffers are created at startup time and stored in a mempool, using the DPDK mempool library.
167fc1f2750SBernard Iremonger
168fc1f2750SBernard IremongerThis library provide an API to allocate/free mbufs, manipulate control message buffers (ctrlmbuf) which are generic message buffers,
169fc1f2750SBernard Iremongerand packet buffers (pktmbuf) which are used to carry network packets.
170fc1f2750SBernard Iremonger
171fc1f2750SBernard IremongerNetwork Packet Buffer Management is described in :ref:`Mbuf Library <Mbuf_Library>`.
172fc1f2750SBernard Iremonger
173fc1f2750SBernard IremongerTimer Manager (librte_timer)
174fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175fc1f2750SBernard Iremonger
176*48624fd9SSiobhan ButlerThis library provides a timer service to DPDK execution units,
177fc1f2750SBernard Iremongerproviding the ability to execute a function asynchronously.
178fc1f2750SBernard IremongerIt can be periodic function calls, or just a one-shot call.
179fc1f2750SBernard IremongerIt uses the timer interface provided by the Environment Abstraction Layer (EAL)
180fc1f2750SBernard Iremongerto get a precise time reference and can be initiated on a per-core basis as required.
181fc1f2750SBernard Iremonger
182fc1f2750SBernard IremongerThe library documentation is available in :ref:`Timer Library <Timer_Library>`.
183fc1f2750SBernard Iremonger
184fc1f2750SBernard IremongerEthernet* Poll Mode Driver Architecture
185fc1f2750SBernard Iremonger---------------------------------------
186fc1f2750SBernard Iremonger
187*48624fd9SSiobhan ButlerThe DPDK includes Poll Mode Drivers (PMDs) for 1 GbE, 10 GbE and 40GbE, and para virtualized virtio
188fc1f2750SBernard IremongerEthernet controllers which are designed to work without asynchronous, interrupt-based signaling mechanisms.
189fc1f2750SBernard Iremonger
190fc1f2750SBernard IremongerSee  :ref:`Poll Mode Driver <Poll_Mode_Driver>`.
191fc1f2750SBernard Iremonger
192fc1f2750SBernard IremongerPacket Forwarding Algorithm Support
193fc1f2750SBernard Iremonger-----------------------------------
194fc1f2750SBernard Iremonger
195*48624fd9SSiobhan ButlerThe DPDK includes Hash (librte_hash) and Longest Prefix Match (LPM,librte_lpm)
196fc1f2750SBernard Iremongerlibraries to support the corresponding packet forwarding algorithms.
197fc1f2750SBernard Iremonger
198fc1f2750SBernard IremongerSee :ref:`Hash Library <Hash_Library>` and  :ref:`LPM Library <LPM_Library>` for more information.
199fc1f2750SBernard Iremonger
200fc1f2750SBernard Iremongerlibrte_net
201fc1f2750SBernard Iremonger----------
202fc1f2750SBernard Iremonger
203fc1f2750SBernard IremongerThe librte_net library is a collection of IP protocol definitions and convenience macros.
204fc1f2750SBernard IremongerIt is based on code from the FreeBSD* IP stack and contains protocol numbers (for use in IP headers),
205fc1f2750SBernard IremongerIP-related macros, IPv4/IPv6 header structures and TCP, UDP and SCTP header structures.
206fc1f2750SBernard Iremonger
207fc1f2750SBernard Iremonger.. |architecture-overview| image:: img/architecture-overview.svg
208