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 3648624fd9SSiobhan ButlerThis section gives a global overview of the architecture of Data Plane Development Kit (DPDK). 37fc1f2750SBernard Iremonger 3848624fd9SSiobhan 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. 4248624fd9SSiobhan 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. 5248624fd9SSiobhan ButlerSample applications are provided to help show the user how to use various features of the DPDK. 53fc1f2750SBernard Iremonger 5448624fd9SSiobhan 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 6748624fd9SSiobhan ButlerThe DPDK project installation requires Linux and the associated toolchain, 68fc1f2750SBernard Iremongersuch as one or more compilers, assembler, make utility, 6948624fd9SSiobhan 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. 7548624fd9SSiobhan 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 8448624fd9SSiobhan 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 9348624fd9SSiobhan 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 115*2fe68f32SJohn McNamara* Memory management (malloc) 11656297061SSergio Gonzalez Monroy 117fc1f2750SBernard IremongerThe EAL is fully described in :ref:`Environment Abstraction Layer <Environment_Abstraction_Layer>`. 118fc1f2750SBernard Iremonger 119fc1f2750SBernard IremongerCore Components 120fc1f2750SBernard Iremonger--------------- 121fc1f2750SBernard Iremonger 122fc1f2750SBernard IremongerThe *core components* are a set of libraries that provide all the elements needed 123fc1f2750SBernard Iremongerfor high-performance packet processing applications. 124fc1f2750SBernard Iremonger 1254a22e6eeSJohn McNamara.. _figure_architecture-overview: 126fc1f2750SBernard Iremonger 1274a22e6eeSJohn McNamara.. figure:: img/architecture-overview.* 128fc1f2750SBernard Iremonger 1294a22e6eeSJohn McNamara Core Components Architecture 130fc1f2750SBernard Iremonger 131fc1f2750SBernard Iremonger 132fc1f2750SBernard IremongerRing Manager (librte_ring) 133fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~ 134fc1f2750SBernard Iremonger 135fc1f2750SBernard IremongerThe ring structure provides a lockless multi-producer, multi-consumer FIFO API in a finite size table. 136fc1f2750SBernard IremongerIt has some advantages over lockless queues; easier to implement, adapted to bulk operations and faster. 137fc1f2750SBernard IremongerA ring is used by the :ref:`Memory Pool Manager (librte_mempool) <Mempool_Library>` 138fc1f2750SBernard Iremongerand may be used as a general communication mechanism between cores 139fc1f2750SBernard Iremongerand/or execution blocks connected together on a logical core. 140fc1f2750SBernard Iremonger 141fc1f2750SBernard IremongerThis ring buffer and its usage are fully described in :ref:`Ring Library <Ring_Library>`. 142fc1f2750SBernard Iremonger 143fc1f2750SBernard IremongerMemory Pool Manager (librte_mempool) 144fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 145fc1f2750SBernard Iremonger 146fc1f2750SBernard IremongerThe Memory Pool Manager is responsible for allocating pools of objects in memory. 147fc1f2750SBernard IremongerA pool is identified by name and uses a ring to store free objects. 148fc1f2750SBernard IremongerIt provides some other optional services, 149fc1f2750SBernard 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. 150fc1f2750SBernard Iremonger 151fc1f2750SBernard IremongerThis memory pool allocator is described in :ref:`Mempool Library <Mempool_Library>`. 152fc1f2750SBernard Iremonger 153fc1f2750SBernard IremongerNetwork Packet Buffer Management (librte_mbuf) 154fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 155fc1f2750SBernard Iremonger 156fc1f2750SBernard IremongerThe mbuf library provides the facility to create and destroy buffers 15748624fd9SSiobhan Butlerthat may be used by the DPDK application to store message buffers. 15848624fd9SSiobhan ButlerThe message buffers are created at startup time and stored in a mempool, using the DPDK mempool library. 159fc1f2750SBernard Iremonger 160fc1f2750SBernard IremongerThis library provide an API to allocate/free mbufs, manipulate control message buffers (ctrlmbuf) which are generic message buffers, 161fc1f2750SBernard Iremongerand packet buffers (pktmbuf) which are used to carry network packets. 162fc1f2750SBernard Iremonger 163fc1f2750SBernard IremongerNetwork Packet Buffer Management is described in :ref:`Mbuf Library <Mbuf_Library>`. 164fc1f2750SBernard Iremonger 165fc1f2750SBernard IremongerTimer Manager (librte_timer) 166fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 167fc1f2750SBernard Iremonger 16848624fd9SSiobhan ButlerThis library provides a timer service to DPDK execution units, 169fc1f2750SBernard Iremongerproviding the ability to execute a function asynchronously. 170fc1f2750SBernard IremongerIt can be periodic function calls, or just a one-shot call. 171fc1f2750SBernard IremongerIt uses the timer interface provided by the Environment Abstraction Layer (EAL) 172fc1f2750SBernard Iremongerto get a precise time reference and can be initiated on a per-core basis as required. 173fc1f2750SBernard Iremonger 174fc1f2750SBernard IremongerThe library documentation is available in :ref:`Timer Library <Timer_Library>`. 175fc1f2750SBernard Iremonger 176fc1f2750SBernard IremongerEthernet* Poll Mode Driver Architecture 177fc1f2750SBernard Iremonger--------------------------------------- 178fc1f2750SBernard Iremonger 17948624fd9SSiobhan ButlerThe DPDK includes Poll Mode Drivers (PMDs) for 1 GbE, 10 GbE and 40GbE, and para virtualized virtio 180fc1f2750SBernard IremongerEthernet controllers which are designed to work without asynchronous, interrupt-based signaling mechanisms. 181fc1f2750SBernard Iremonger 182fc1f2750SBernard IremongerSee :ref:`Poll Mode Driver <Poll_Mode_Driver>`. 183fc1f2750SBernard Iremonger 184fc1f2750SBernard IremongerPacket Forwarding Algorithm Support 185fc1f2750SBernard Iremonger----------------------------------- 186fc1f2750SBernard Iremonger 18748624fd9SSiobhan ButlerThe DPDK includes Hash (librte_hash) and Longest Prefix Match (LPM,librte_lpm) 188fc1f2750SBernard Iremongerlibraries to support the corresponding packet forwarding algorithms. 189fc1f2750SBernard Iremonger 190fc1f2750SBernard IremongerSee :ref:`Hash Library <Hash_Library>` and :ref:`LPM Library <LPM_Library>` for more information. 191fc1f2750SBernard Iremonger 192fc1f2750SBernard Iremongerlibrte_net 193fc1f2750SBernard Iremonger---------- 194fc1f2750SBernard Iremonger 195fc1f2750SBernard IremongerThe librte_net library is a collection of IP protocol definitions and convenience macros. 196fc1f2750SBernard IremongerIt is based on code from the FreeBSD* IP stack and contains protocol numbers (for use in IP headers), 197fc1f2750SBernard IremongerIP-related macros, IPv4/IPv6 header structures and TCP, UDP and SCTP header structures. 198