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 33Overview 34======== 35 36This section gives a global overview of the architecture of Data Plane Development Kit (DPDK). 37 38The main goal of the DPDK is to provide a simple, 39complete framework for fast packet processing in data plane applications. 40Users may use the code to understand some of the techniques employed, 41to build upon for prototyping or to add their own protocol stacks. 42Alternative ecosystem options that use the DPDK are available. 43 44The framework creates a set of libraries for specific environments 45through the creation of an Environment Abstraction Layer (EAL), 46which may be specific to a mode of the Intel® architecture (32-bit or 64-bit), 47Linux* user space compilers or a specific platform. 48These environments are created through the use of make files and configuration files. 49Once the EAL library is created, the user may link with the library to create their own applications. 50Other libraries, outside of EAL, including the Hash, 51Longest Prefix Match (LPM) and rings libraries are also provided. 52Sample applications are provided to help show the user how to use various features of the DPDK. 53 54The DPDK implements a run to completion model for packet processing, 55where all resources must be allocated prior to calling Data Plane applications, 56running as execution units on logical processing cores. 57The model does not support a scheduler and all devices are accessed by polling. 58The primary reason for not using interrupts is the performance overhead imposed by interrupt processing. 59 60In addition to the run-to-completion model, 61a pipeline model may also be used by passing packets or messages between cores via the rings. 62This allows work to be performed in stages and may allow more efficient use of code on cores. 63 64Development Environment 65----------------------- 66 67The DPDK project installation requires Linux and the associated toolchain, 68such as one or more compilers, assembler, make utility, 69editor and various libraries to create the DPDK components and libraries. 70 71Once these libraries are created for the specific environment and architecture, 72they may then be used to create the user's data plane application. 73 74When creating applications for the Linux user space, the glibc library is used. 75For DPDK applications, two environmental variables (RTE_SDK and RTE_TARGET) 76must be configured before compiling the applications. 77The 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 84See the *DPDK Getting Started Guide* for information on setting up the development environment. 85 86Environment Abstraction Layer 87----------------------------- 88 89The Environment Abstraction Layer (EAL) provides a generic interface 90that hides the environment specifics from the applications and libraries. 91The 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 115The EAL is fully described in :ref:`Environment Abstraction Layer <Environment_Abstraction_Layer>`. 116 117Core Components 118--------------- 119 120The *core components* are a set of libraries that provide all the elements needed 121for high-performance packet processing applications. 122 123.. _figure_architecture-overview: 124 125.. figure:: img/architecture-overview.* 126 127 Core Components Architecture 128 129 130Memory Manager (librte_malloc) 131~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 132 133The librte_malloc library provides an API to allocate memory from the memzones created from the hugepages instead of the heap. 134This helps when allocating large numbers of items that may become susceptible to TLB misses 135when using typical 4k heap pages in the Linux user space environment. 136 137This memory allocator is fully described in :ref:`Malloc Library <Malloc_Library>`. 138 139Ring Manager (librte_ring) 140~~~~~~~~~~~~~~~~~~~~~~~~~~ 141 142The ring structure provides a lockless multi-producer, multi-consumer FIFO API in a finite size table. 143It has some advantages over lockless queues; easier to implement, adapted to bulk operations and faster. 144A ring is used by the :ref:`Memory Pool Manager (librte_mempool) <Mempool_Library>` 145and may be used as a general communication mechanism between cores 146and/or execution blocks connected together on a logical core. 147 148This ring buffer and its usage are fully described in :ref:`Ring Library <Ring_Library>`. 149 150Memory Pool Manager (librte_mempool) 151~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 152 153The Memory Pool Manager is responsible for allocating pools of objects in memory. 154A pool is identified by name and uses a ring to store free objects. 155It provides some other optional services, 156such 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 158This memory pool allocator is described in :ref:`Mempool Library <Mempool_Library>`. 159 160Network Packet Buffer Management (librte_mbuf) 161~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 162 163The mbuf library provides the facility to create and destroy buffers 164that may be used by the DPDK application to store message buffers. 165The message buffers are created at startup time and stored in a mempool, using the DPDK mempool library. 166 167This library provide an API to allocate/free mbufs, manipulate control message buffers (ctrlmbuf) which are generic message buffers, 168and packet buffers (pktmbuf) which are used to carry network packets. 169 170Network Packet Buffer Management is described in :ref:`Mbuf Library <Mbuf_Library>`. 171 172Timer Manager (librte_timer) 173~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 174 175This library provides a timer service to DPDK execution units, 176providing the ability to execute a function asynchronously. 177It can be periodic function calls, or just a one-shot call. 178It uses the timer interface provided by the Environment Abstraction Layer (EAL) 179to get a precise time reference and can be initiated on a per-core basis as required. 180 181The library documentation is available in :ref:`Timer Library <Timer_Library>`. 182 183Ethernet* Poll Mode Driver Architecture 184--------------------------------------- 185 186The DPDK includes Poll Mode Drivers (PMDs) for 1 GbE, 10 GbE and 40GbE, and para virtualized virtio 187Ethernet controllers which are designed to work without asynchronous, interrupt-based signaling mechanisms. 188 189See :ref:`Poll Mode Driver <Poll_Mode_Driver>`. 190 191Packet Forwarding Algorithm Support 192----------------------------------- 193 194The DPDK includes Hash (librte_hash) and Longest Prefix Match (LPM,librte_lpm) 195libraries to support the corresponding packet forwarding algorithms. 196 197See :ref:`Hash Library <Hash_Library>` and :ref:`LPM Library <LPM_Library>` for more information. 198 199librte_net 200---------- 201 202The librte_net library is a collection of IP protocol definitions and convenience macros. 203It is based on code from the FreeBSD* IP stack and contains protocol numbers (for use in IP headers), 204IP-related macros, IPv4/IPv6 header structures and TCP, UDP and SCTP header structures. 205