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.
32 =========================
34 This chapter describes how a developer can extend the DPDK to provide a new library,
35 a new target, or support a new target.
37 Example: Adding a New Library libfoo
38 ------------------------------------
40 To add a new library to the DPDK, proceed as follows:
42 #. Add a new configuration option:
46 for f in config/\*; do \
47 echo CONFIG_RTE_LIBFOO=y >> $f; done
49 #. Create a new directory with sources:
51 .. code-block:: console
53 mkdir ${RTE_SDK}/lib/libfoo
54 touch ${RTE_SDK}/lib/libfoo/foo.c
55 touch ${RTE_SDK}/lib/libfoo/foo.h
57 #. Add a foo() function in libfoo.
59 Definition is in foo.c:
67 Declaration is in foo.h:
71 extern void foo(void);
74 #. Update lib/Makefile:
76 .. code-block:: console
78 vi ${RTE_SDK}/lib/Makefile
80 # DIRS-$(CONFIG_RTE_LIBFOO) += libfoo
82 #. Create a new Makefile for this library, for example, derived from mempool Makefile:
84 .. code-block:: console
86 cp ${RTE_SDK}/lib/librte_mempool/Makefile ${RTE_SDK}/lib/libfoo/
88 vi ${RTE_SDK}/lib/libfoo/Makefile
90 # librte_mempool -> libfoo
94 #. Update mk/DPDK.app.mk, and add -lfoo in LDLIBS variable when the option is enabled.
95 This will automatically add this flag when linking a DPDK application.
98 #. Build the DPDK with the new library (we only show a specific target here):
100 .. code-block:: console
103 make config T=x86_64-native-linuxapp-gcc
107 #. Check that the library is installed:
109 .. code-block:: console
114 Example: Using libfoo in the Test Application
115 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
117 The test application is used to validate all functionality of the DPDK.
118 Once you have added a library, a new test case should be added in the test application.
120 * A new test_foo.c file should be added, that includes foo.h and calls the foo() function from test_foo().
121 When the test passes, the test_foo() function should return 0.
123 * Makefile, test.h and commands.c must be updated also, to handle the new test case.
125 * Test report generation: autotest.py is a script that is used to generate the test report that is available in the
126 ${RTE_SDK}/doc/rst/test_report/autotests directory. This script must be updated also.
127 If libfoo is in a new test family, the links in ${RTE_SDK}/doc/rst/test_report/test_report.rst must be updated.
129 * Build the DPDK with the updated test application (we only show a specific target here):
132 .. code-block:: console
135 make config T=x86_64-native-linuxapp-gcc