2 Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
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
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.
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.
31 Compiling and Running Sample Applications
32 =========================================
34 The chapter describes how to compile and run applications in an Intel® DPDK environment.
35 It also provides a pointer to where sample applications are stored.
37 Compiling a Sample Application
38 ------------------------------
40 Once an Intel® DPDK target environment directory has been created (such as x86_64-native-bsdapp-gcc),
41 it contains all libraries and header files required to build an application.
43 When compiling an application in the FreeBSD* environment on the Intel® DPDK,
44 the following variables must be exported:
46 * RTE_SDK - Points to the Intel® DPDK installation directory.
48 * RTE_TARGET - Points to the Intel® DPDK target environment directory.
49 For FreeBSD*, this is the x86_64-native-bsdapp-gcc directory.
51 The following is an example of creating the helloworld application,
52 which runs in the Intel® DPDK FreeBSD* environment.
53 This example may be found in the ${RTE_SDK}/examples directory.
55 The directory contains the main.c file.
56 This file, when combined with the libraries in the Intel® DPDK target environment,
57 calls the various functions to initialize the Intel® DPDK environment,
58 then launches an entry point (dispatch application) for each core to be utilized.
59 By default, the binary is generated in the build directory.
61 .. code-block:: console
63 user@host:~/DPDK$ cd examples/helloworld/
64 user@host:~/DPDK/examples/helloworld$ setenv RTE_SDK $HOME/DPDK
65 user@host:~/DPDK/examples/helloworld$ setenv RTE_TARGET x86_64-native-bsdapp-gcc
66 user@host:~/DPDK/examples/helloworld$ gmake CC=gcc48
69 INSTALL-APP helloworld
70 INSTALL-MAP helloworld.map
71 user@host:~/DPDK/examples/helloworld$ ls build/app
72 helloworld helloworld.map
76 In the above example, helloworld was in the directory structure of the Intel® DPDK.
77 However, it could have been located outside the directory structure to keep the Intel® DPDK structure intact.
78 In the following case, the helloworld application is copied to a new directory as a new starting point.
80 .. code-block:: console
82 user@host:~$ setenv RTE_SDK /home/user/DPDK
83 user@host:~$ cp -r $(RTE_SDK)/examples/helloworld my_rte_app
84 user@host:~$ cd my_rte_app/
85 user@host:~$ setenv RTE_TARGET x86_64-native-bsdapp-gcc
86 user@host:~/my_rte_app$ gmake CC=gcc48
89 INSTALL-APP helloworld
90 INSTALL-MAP helloworld.map
92 Running a Sample Application
93 ----------------------------
95 #. The contigmem and nic_uio modules must be set up prior to running an application.
97 #. Any ports to be used by the application must be already bound to the nic_uio module,
98 as described in section Section 3.6, “ , ” prior to running the application.
99 The application is linked with the Intel® DPDK target environment's Environment Abstraction Layer (EAL) library,
100 which provides some options that are generic to every Intel® DPDK application.
102 The following is the list of options that can be given to the EAL:
104 .. code-block:: console
106 ./rte-app -c COREMASK -n NUM [-b <domain:bus:devid.func>] [-m MB] [-r NUM] [-v] [--file-prefix] [--proc-type <primary|secondary|auto>]
110 EAL has a common interface between all operating systems and is based on the Linux* notation for PCI devices.
111 The device and function separator used is a ":" rather than "." as seen with pciconf on FreeBSD*.
112 For example, a FreeBSD* device selector of pci0:2:0:1 is referred to as 02:00.1 in EAL.
114 The EAL options for FreeBSD* are as follows:
117 : A hexadecimal bit mask of the cores to run on.
118 Note that core numbering can change between platforms and should be determined beforehand.
121 : Number of memory channels per processor socket.
123 * -b <domain:bus:devid.func>
124 : blacklisting of ports; prevent EAL from using specified PCI device (multiple -b options are allowed).
127 : use the specified ethernet device(s) only.
128 Use comma-separate <[domain:]bus:devid.func> values. Cannot be used with -b option.
131 : Number of memory ranks.
134 : Display version information on startup.
137 : The type of process instance.
139 Other options, specific to Linux* and are not supported under FreeBSD* are as follows:
142 : Memory to allocate from hugepages on specific sockets.
145 : The directory where hugetlbfs is mounted.
148 : The prefix text used for hugepage filenames.
151 : Memory to allocate from hugepages, regardless of processor socket.
152 It is recommended that --socket-mem be used instead of this option.
154 The -c and the -n options are mandatory; the others are optional.
156 Copy the Intel® DPDK application binary to your target,
157 then run the application as follows (assuming the platform has four memory channels,
158 and that cores 0-3 are present and are to be used for running the application):
160 .. code-block:: console
162 root@target:~$ ./helloworld -c f -n 4
166 The --proc-type and --file-prefix EAL options are used for running multiple Intel® DPDK processes.
167 See the “Multi-process Sample Application” chapter in the
168 *Intel® DPDK Sample Applications User Guide and the Intel® DPDK Programmers Guide* for more details.
170 Running Intel®DPDK Applications Without Root Privileges
171 -------------------------------------------------------
173 Although applications using the Intel® DPDK use network ports and other hardware resources directly,
174 with a number of small permission adjustments,
175 it is possible to run these applications as a user other than “root”.
176 To do so, the ownership, or permissions, on the following file system objects should be adjusted to ensure
177 that the user account being used to run the Intel® DPDK application has access to them:
179 * The userspace-io device files in /dev, for example, /dev/uio0, /dev/uio1, and so on
181 * The userspace contiguous memory device: /dev/contigmem
185 Please refer to the Intel® DPDK Release Notes for supported applications.