4 Environment or Architecture-specific Sources
5 --------------------------------------------
7 In DPDK and DPDK applications, some code is specific to an architecture (i686, x86_64) or to an executive environment (bsdapp or linuxapp) and so on.
8 As far as is possible, all such instances of architecture or env-specific code should be provided via standard APIs in the EAL.
10 By convention, a file is common if it is not located in a directory indicating that it is specific.
11 For instance, a file located in a subdir of "x86_64" directory is specific to this architecture.
12 A file located in a subdir of "linuxapp" is specific to this execution environment.
16 Code in DPDK libraries and applications should be generic.
17 The correct location for architecture or executive environment specific code is in the EAL.
19 When absolutely necessary, there are several ways to handle specific code:
21 * Use a ``#ifdef`` with the CONFIG option in the C code.
22 This can be done when the differences are small and they can be embedded in the same C file:
32 * Use the CONFIG option in the Makefile. This is done when the differences are more significant.
33 In this case, the code is split into two separate files that are architecture or environment specific.
34 This should only apply inside the EAL library.
38 As in the linux kernel, the ``CONFIG_`` prefix is not used in C code.
39 This is only needed in Makefiles or shell scripts.
41 Per Architecture Sources
42 ~~~~~~~~~~~~~~~~~~~~~~~~
44 The following config options can be used:
46 * ``CONFIG_RTE_ARCH`` is a string that contains the name of the architecture.
47 * ``CONFIG_RTE_ARCH_I686``, ``CONFIG_RTE_ARCH_X86_64``, ``CONFIG_RTE_ARCH_X86_64_32`` or ``CONFIG_RTE_ARCH_PPC_64`` are defined only if we are building for those architectures.
49 Per Execution Environment Sources
50 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52 The following config options can be used:
54 * ``CONFIG_RTE_EXEC_ENV`` is a string that contains the name of the executive environment.
55 * ``CONFIG_RTE_EXEC_ENV_BSDAPP`` or ``CONFIG_RTE_EXEC_ENV_LINUXAPP`` are defined only if we are building for this execution environment.
63 This document describes the guidelines for DPDK library-level statistics counter
64 support. This includes guidelines for turning library statistics on and off and
65 requirements for preventing ABI changes when implementing statistics.
68 Mechanism to allow the application to turn library statistics on and off
69 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71 Each library that maintains statistics counters should provide a single build
72 time flag that decides whether the statistics counter collection is enabled or
73 not. This flag should be exposed as a variable within the DPDK configuration
74 file. When this flag is set, all the counters supported by current library are
75 collected for all the instances of every object type provided by the library.
76 When this flag is cleared, none of the counters supported by the current library
77 are collected for any instance of any object type provided by the library:
79 .. code-block:: console
81 # DPDK file config/common_linuxapp, config/common_bsdapp, etc.
82 CONFIG_RTE_<LIBRARY_NAME>_STATS_COLLECT=y/n
84 The default value for this DPDK configuration file variable (either "yes" or
85 "no") is decided by each library.
88 Prevention of ABI changes due to library statistics support
89 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91 The layout of data structures and prototype of functions that are part of the
92 library API should not be affected by whether the collection of statistics
93 counters is turned on or off for the current library. In practical terms, this
94 means that space should always be allocated in the API data structures for
95 statistics counters and the statistics related API functions are always built
96 into the code, regardless of whether the statistics counter collection is turned
97 on or off for the current library.
99 When the collection of statistics counters for the current library is turned
100 off, the counters retrieved through the statistics related API functions should
101 have a default value of zero.
104 Motivation to allow the application to turn library statistics on and off
105 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107 It is highly recommended that each library provides statistics counters to allow
108 an application to monitor the library-level run-time events. Typical counters
109 are: number of packets received/dropped/transmitted, number of buffers
110 allocated/freed, number of occurrences for specific events, etc.
112 However, the resources consumed for library-level statistics counter collection
113 have to be spent out of the application budget and the counters collected by
114 some libraries might not be relevant to the current application. In order to
115 avoid any unwanted waste of resources and/or performance impacts, the
116 application should decide at build time whether the collection of library-level
117 statistics counters should be turned on or off for each library individually.
119 Library-level statistics counters can be relevant or not for specific
122 * For Application A, counters maintained by Library X are always relevant and
123 the application needs to use them to implement certain features, such as traffic
124 accounting, logging, application-level statistics, etc. In this case,
125 the application requires that collection of statistics counters for Library X is
128 * For Application B, counters maintained by Library X are only useful during the
129 application debug stage and are not relevant once debug phase is over. In this
130 case, the application may decide to turn on the collection of Library X
131 statistics counters during the debug phase and at a later stage turn them off.
133 * For Application C, counters maintained by Library X are not relevant at all.
134 It might be that the application maintains its own set of statistics counters
135 that monitor a different set of run-time events (e.g. number of connection
136 requests, number of active users, etc). It might also be that the application
137 uses multiple libraries (Library X, Library Y, etc) and it is interested in the
138 statistics counters of Library Y, but not in those of Library X. In this case,
139 the application may decide to turn the collection of statistics counters off for
140 Library X and on for Library Y.
142 The statistics collection consumes a certain amount of CPU resources (cycles,
143 cache bandwidth, memory bandwidth, etc) that depends on:
145 * Number of libraries used by the current application that have statistics
146 counters collection turned on.
148 * Number of statistics counters maintained by each library per object type
149 instance (e.g. per port, table, pipeline, thread, etc).
151 * Number of instances created for each object type supported by each library.
153 * Complexity of the statistics logic collection for each counter: when only
154 some occurrences of a specific event are valid, additional logic is typically
155 needed to decide whether the current occurrence of the event should be counted
156 or not. For example, in the event of packet reception, when only TCP packets
157 with destination port within a certain range should be recorded, conditional
158 branches are usually required. When processing a burst of packets that have been
159 validated for header integrity, counting the number of bits set in a bitmask
162 PF and VF Considerations
163 ------------------------
165 The primary goal of DPDK is to provide a userspace dataplane. Managing VFs from
166 a PF driver is a control plane feature and developers should generally rely on
167 the Linux Kernel for that.
169 Developers should work with the Linux Kernel community to get the required
170 functionality upstream. PF functionality should only be added to DPDK for
171 testing and prototyping purposes while the kernel work is ongoing. It should
172 also be marked with an "EXPERIMENTAL" tag. If the functionality isn't
173 upstreamable then a case can be made to maintain the PF functionality in DPDK
174 without the EXPERIMENTAL tag.