1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2010-2014 Intel Corporation.
5 =========================
7 This chapter describes how a developer can extend the DPDK to provide a new library,
8 a new target, or support a new target.
10 Example: Adding a New Library libfoo
11 ------------------------------------
13 To add a new library to the DPDK, proceed as follows:
15 #. Add a new configuration option:
19 for f in config/\*; do \
20 echo CONFIG_RTE_LIBFOO=y >> $f; done
22 #. Create a new directory with sources:
24 .. code-block:: console
26 mkdir ${RTE_SDK}/lib/libfoo
27 touch ${RTE_SDK}/lib/libfoo/foo.c
28 touch ${RTE_SDK}/lib/libfoo/foo.h
30 #. Add a foo() function in libfoo.
32 Definition is in foo.c:
40 Declaration is in foo.h:
44 extern void foo(void);
47 #. Update lib/Makefile:
49 .. code-block:: console
51 vi ${RTE_SDK}/lib/Makefile
53 # DIRS-$(CONFIG_RTE_LIBFOO) += libfoo
55 #. Create a new Makefile for this library, for example, derived from mempool Makefile:
57 .. code-block:: console
59 cp ${RTE_SDK}/lib/librte_mempool/Makefile ${RTE_SDK}/lib/libfoo/
61 vi ${RTE_SDK}/lib/libfoo/Makefile
63 # librte_mempool -> libfoo
67 #. Update mk/DPDK.app.mk, and add -lfoo in LDLIBS variable when the option is enabled.
68 This will automatically add this flag when linking a DPDK application.
71 #. Build the DPDK with the new library (we only show a specific target here):
73 .. code-block:: console
76 make config T=x86_64-native-linux-gcc
80 #. Check that the library is installed:
82 .. code-block:: console
87 Example: Using libfoo in the Test Application
88 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90 The test application is used to validate all functionality of the DPDK.
91 Once you have added a library, a new test case should be added in the test application.
93 * A new test_foo.c file should be added, that includes foo.h and calls the foo() function from test_foo().
94 When the test passes, the test_foo() function should return 0.
96 * Makefile, test.h and commands.c must be updated also, to handle the new test case.
98 * Test report generation: autotest.py is a script that is used to generate the test report that is available in the
99 ${RTE_SDK}/doc/rst/test_report/autotests directory. This script must be updated also.
100 If libfoo is in a new test family, the links in ${RTE_SDK}/doc/rst/test_report/test_report.rst must be updated.
102 * Build the DPDK with the updated test application (we only show a specific target here):
105 .. code-block:: console
108 make config T=x86_64-native-linux-gcc