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