b4ae1d1e59b0d03a9b0ecbf57de3f05498eebe74
[dpdk.git] / doc / guides / guidelines / design.rst
1 Design
2 ======
3
4 Environment or Architecture-specific Sources
5 --------------------------------------------
6
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.
9
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.
13
14 .. note::
15
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.
18
19 When absolutely necessary, there are several ways to handle specific code:
20
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:
23
24 .. code-block: console
25
26    #ifdef RTE_ARCH_I686
27    toto();
28    #else
29    titi();
30    #endif
31
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.  This should only apply inside the EAL library.
34
35 .. note:
36
37         As in the linux kernel, the "CONFIG_" prefix is not used in C code.
38         This is only needed in Makefiles or shell scripts.
39
40 Per Architecture Sources
41 ~~~~~~~~~~~~~~~~~~~~~~~~
42
43 The following config options can be used:
44
45 * CONFIG_RTE_ARCH is a string that contains the name of the architecture.
46 * 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.
47
48 Per Execution Environment Sources
49 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50
51 The following config options can be used:
52
53 * CONFIG_RTE_EXEC_ENV is a string that contains the name of the executive environment.
54 * CONFIG_RTE_EXEC_ENV_BSDAPP or CONFIG_RTE_EXEC_ENV_LINUXAPP are defined only if we are building for this execution environment.