7bd6b03f10326ac89af1599ba0aeedbae73a0a3b
[dpdk.git] / doc / guides / linux_gsg / enable_func.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright(c) 2010-2014 Intel Corporation.
3
4 .. _Enabling_Additional_Functionality:
5
6 Enabling Additional Functionality
7 =================================
8
9 .. _High_Precision_Event_Timer:
10
11 High Precision Event Timer (HPET) Functionality
12 -----------------------------------------------
13
14 BIOS Support
15 ~~~~~~~~~~~~
16
17 The High Precision Timer (HPET) must be enabled in the platform BIOS if the HPET is to be used.
18 Otherwise, the Time Stamp Counter (TSC) is used by default.
19 The BIOS is typically accessed by pressing F2 while the platform is starting up.
20 The user can then navigate to the HPET option. On the Crystal Forest platform BIOS, the path is:
21 **Advanced -> PCH-IO Configuration -> High Precision Timer ->** (Change from Disabled to Enabled if necessary).
22
23 On a system that has already booted, the following command can be issued to check if HPET is enabled::
24
25    grep hpet /proc/timer_list
26
27 If no entries are returned, HPET must be enabled in the BIOS (as per the instructions above) and the system rebooted.
28
29 Linux Kernel Support
30 ~~~~~~~~~~~~~~~~~~~~
31
32 The DPDK makes use of the platform HPET timer by mapping the timer counter into the process address space, and as such,
33 requires that the ``HPET_MMAP`` kernel configuration option be enabled.
34
35 .. warning::
36
37     On Fedora, and other common distributions such as Ubuntu, the ``HPET_MMAP`` kernel option is not enabled by default.
38     To recompile the Linux kernel with this option enabled, please consult the distributions documentation for the relevant instructions.
39
40 Enabling HPET in the DPDK
41 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42
43 By default, HPET support is disabled in the DPDK build configuration files.
44 To use HPET, use the following meson build option which will enable the HPET settings at compile time::
45
46    meson configure -Duse_hpet=true
47
48 For an application to use the ``rte_get_hpet_cycles()`` and ``rte_get_hpet_hz()`` API calls,
49 and optionally to make the HPET the default time source for the rte_timer library,
50 the new ``rte_eal_hpet_init()`` API call should be called at application initialization.
51 This API call will ensure that the HPET is accessible, returning an error to the application if it is not,
52 for example, if ``HPET_MMAP`` is not enabled in the kernel.
53 The application can then determine what action to take, if any, if the HPET is not available at run-time.
54
55 .. note::
56
57     For applications that require timing APIs, but not the HPET timer specifically,
58     it is recommended that the ``rte_get_timer_cycles()`` and ``rte_get_timer_hz()`` API calls be used instead of the HPET-specific APIs.
59     These generic APIs can work with either TSC or HPET time sources, depending on what is requested by an application call to ``rte_eal_hpet_init()``,
60     if any, and on what is available on the system at runtime.
61
62 .. _Running_Without_Root_Privileges:
63
64 Running DPDK Applications Without Root Privileges
65 -------------------------------------------------
66
67 In order to run DPDK as non-root, the following Linux filesystem objects'
68 permissions should be adjusted to ensure that the Linux account being used to
69 run the DPDK application has access to them:
70
71 *   All directories which serve as hugepage mount points, for example, ``/dev/hugepages``
72
73 *   If the HPET is to be used,  ``/dev/hpet``
74
75 When running as non-root user, there may be some additional resource limits
76 that are imposed by the system. Specifically, the following resource limits may
77 need to be adjusted in order to ensure normal DPDK operation:
78
79 * RLIMIT_LOCKS (number of file locks that can be held by a process)
80
81 * RLIMIT_NOFILE (number of open file descriptors that can be held open by a process)
82
83 * RLIMIT_MEMLOCK (amount of pinned pages the process is allowed to have)
84
85 The above limits can usually be adjusted by editing
86 ``/etc/security/limits.conf`` file, and rebooting.
87
88 Additionally, depending on which kernel driver is in use, the relevant
89 resources also should be accessible by the user running the DPDK application.
90
91 For ``vfio-pci`` kernel driver, the following Linux file system objects'
92 permissions should be adjusted:
93
94 * The VFIO device file, ``/dev/vfio/vfio``
95
96 * The directories under ``/dev/vfio`` that correspond to IOMMU group numbers of
97   devices intended to be used by DPDK, for example, ``/dev/vfio/50``
98
99 .. note::
100
101     The instructions below will allow running DPDK with ``igb_uio`` or
102     ``uio_pci_generic`` drivers as non-root with older Linux kernel versions.
103     However, since version 4.0, the kernel does not allow unprivileged processes
104     to read the physical address information from the pagemaps file, making it
105     impossible for those processes to be used by non-privileged users. In such
106     cases, using the VFIO driver is recommended.
107
108 For ``igb_uio`` or ``uio_pci_generic`` kernel drivers, the following Linux file
109 system objects' permissions should be adjusted:
110
111 *   The userspace-io device files in  ``/dev``, for example,  ``/dev/uio0``, ``/dev/uio1``, and so on
112
113 *   The userspace-io sysfs config and resource files, for example for ``uio0``::
114
115        /sys/class/uio/uio0/device/config
116        /sys/class/uio/uio0/device/resource*
117
118
119 Power Management and Power Saving Functionality
120 -----------------------------------------------
121
122 Enhanced Intel SpeedStep® Technology must be enabled in the platform BIOS if the power management feature of DPDK is to be used.
123 Otherwise, the sys file folder ``/sys/devices/system/cpu/cpu0/cpufreq`` will not exist, and the CPU frequency- based power management cannot be used.
124 Consult the relevant BIOS documentation to determine how these settings can be accessed.
125
126 For example, on some Intel reference platform BIOS variants, the path to Enhanced Intel SpeedStep® Technology is::
127
128    Advanced
129      -> Processor Configuration
130      -> Enhanced Intel SpeedStep® Tech
131
132 In addition, C3 and C6 should be enabled as well for power management. The path of C3 and C6 on the same platform BIOS is::
133
134    Advanced
135      -> Processor Configuration
136      -> Processor C3 Advanced
137      -> Processor Configuration
138      -> Processor C6
139
140 Using Linux Core Isolation to Reduce Context Switches
141 -----------------------------------------------------
142
143 While the threads used by a DPDK application are pinned to logical cores on the system,
144 it is possible for the Linux scheduler to run other tasks on those cores also.
145 To help prevent additional workloads from running on those cores,
146 it is possible to use the ``isolcpus`` Linux kernel parameter to isolate them from the general Linux scheduler.
147
148 For example, if DPDK applications are to run on logical cores 2, 4 and 6,
149 the following should be added to the kernel parameter list:
150
151 .. code-block:: console
152
153     isolcpus=2,4,6
154
155 Loading the DPDK KNI Kernel Module
156 ----------------------------------
157
158 To run the DPDK Kernel NIC Interface (KNI) sample application, an extra kernel module (the kni module) must be loaded into the running kernel.
159 The module is found in the kernel/linux sub-directory of the DPDK build directory.
160 It should be loaded using the insmod command::
161
162    insmod <build_dir>/kernel/linux/kni/rte_kni.ko
163
164 .. note::
165
166    See the "Kernel NIC Interface Sample Application" chapter in the *DPDK Sample Applications User Guide* for more details.
167
168 Using Linux IOMMU Pass-Through to Run DPDK with Intel® VT-d
169 -----------------------------------------------------------
170
171 To enable Intel® VT-d in a Linux kernel, a number of kernel configuration options must be set. These include:
172
173 *   ``IOMMU_SUPPORT``
174
175 *   ``IOMMU_API``
176
177 *   ``INTEL_IOMMU``
178
179 In addition, to run the DPDK with Intel® VT-d, the ``iommu=pt`` kernel parameter must be used when using ``igb_uio`` driver.
180 This results in pass-through of the DMAR (DMA Remapping) lookup in the host.
181 Also, if ``INTEL_IOMMU_DEFAULT_ON`` is not set in the kernel, the ``intel_iommu=on`` kernel parameter must be used too.
182 This ensures that the Intel IOMMU is being initialized as expected.
183
184 Please note that while using ``iommu=pt`` is compulsory for ``igb_uio`` driver,
185 the ``vfio-pci`` driver can actually work with both ``iommu=pt`` and ``iommu=on``.