Update DPDK to 16.07 in Nested VM
[csit.git] / resources / tools / disk-image-builder / nested / buildroot-patches / dpdk.patch
1 diff --git a/package/Config.in b/package/Config.in
2 index 6fc0466..ab38a76 100644
3 --- a/package/Config.in
4 +++ b/package/Config.in
5 @@ -1095,6 +1095,7 @@ menu "Networking"
6         source "package/cgic/Config.in"
7         source "package/cppzmq/Config.in"
8         source "package/czmq/Config.in"
9 +       source "package/dpdk/Config.in"
10         source "package/filemq/Config.in"
11         source "package/flickcurl/Config.in"
12         source "package/fmlib/Config.in"
13 diff --git a/package/dpdk/Config.in b/package/dpdk/Config.in
14 new file mode 100644
15 index 0000000..a42271e
16 --- /dev/null
17 +++ b/package/dpdk/Config.in
18 @@ -0,0 +1,54 @@
19 +config BR2_PACKAGE_DPDK
20 +       bool "dpdk"
21 +       depends on (BR2_i386 && !BR2_x86_i386 && !BR2_x86_i486 \
22 +                     && !BR2_x86_i586 && !BR2_x86_x1000) \
23 +                 || BR2_x86_64 || BR2_ARM_CPU_ARMV7A || BR2_aarch64 \
24 +                  || BR2_aarch64_be
25 +       depends on BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_UCLIBC
26 +       depends on BR2_TOOLCHAIN_HAS_SYNC_1
27 +       depends on BR2_TOOLCHAIN_HAS_SYNC_2
28 +       depends on BR2_TOOLCHAIN_HAS_SYNC_4
29 +       depends on BR2_TOOLCHAIN_HAS_SYNC_8
30 +       help
31 +        DPDK is a set of libraries and drivers for fast packet processing. It
32 +        was designed to run on any processors, however, Intel x86 has been the
33 +        first CPU to be supported. Ports for other CPUs like IBM Power 8 and
34 +        ARM are under progress. It runs mostly in Linux userland. A FreeBSD
35 +        port is now available for a subset of DPDK features.
36 +
37 +        Notes:
38 +        * To build the included Linux Kernel drivers, it is necessary to
39 +          enable CONFIG_PCI_MSI, CONFIG_UIO.
40 +        * To build the PCAP PMD properly, you need to enable the libpcap
41 +          manually.
42 +        * You may need to install the python2 interpreter if you want to use
43 +          scripts dpdk_nic_bind.py and cpu_layout.py
44 +
45 +         http://www.dpdk.org/
46 +
47 +if BR2_PACKAGE_DPDK
48 +
49 +config BR2_PACKAGE_DPDK_CONFIG
50 +       string "Configuration"
51 +       default "i686-native-linuxapp-gcc" \
52 +               if BR2_x86_i686
53 +       default "x86_64-native-linuxapp-gcc" \
54 +               if BR2_x86_64
55 +       default "arm-armv7a-linuxapp-gcc" \
56 +               if BR2_ARM_CPU_ARMV7A
57 +       default "arm64-armv8a-linuxapp-gcc" \
58 +               if BR2_aarch64 || BR2_aarch64_be
59 +
60 +config BR2_PACKAGE_DPDK_TEST
61 +       bool "Install tests suite"
62 +       select BR2_PACKAGE_PYTHON_PEXPECT if BR2_PACKAGE_PYTHON
63 +       help
64 +         Install all DPDK tests. If you want to run the tests by the included
65 +         autotest.py script you need to enable python manually.
66 +
67 +config BR2_PACKAGE_DPDK_EXAMPLES
68 +       bool "Build & install examples"
69 +       help
70 +         Build and install all examples selected by the current configuration.
71 +
72 +endif
73 diff --git a/package/dpdk/dpdk.hash b/package/dpdk/dpdk.hash
74 new file mode 100644
75 index 0000000..1c47f19
76 --- /dev/null
77 +++ b/package/dpdk/dpdk.hash
78 @@ -0,0 +1,2 @@
79 +# Locally calculated
80 +sha256 cc982455a74357e465112bede5c29451b6eeb35f8c1c0dcea280dd3e7829f0e9  dpdk-16.07.tar.gz
81 diff --git a/package/dpdk/dpdk.mk b/package/dpdk/dpdk.mk
82 new file mode 100644
83 index 0000000..02860fd
84 --- /dev/null
85 +++ b/package/dpdk/dpdk.mk
86 @@ -0,0 +1,128 @@
87 +################################################################################
88 +#
89 +# dpdk
90 +#
91 +################################################################################
92 +
93 +DPDK_VERSION = 16.07
94 +DPDK_SITE = http://dpdk.org/browse/dpdk/snapshot
95 +DPDK_SOURCE = dpdk-$(DPDK_VERSION).tar.gz
96 +
97 +DPDK_LICENSE = BSD (core), GPLv2+ (Linux drivers)
98 +DPDK_LICENSE_FILES = GNUmakefile LICENSE.GPL
99 +DPDK_INSTALL_STAGING = YES
100 +
101 +DPDK_DEPENDENCIES += linux
102 +
103 +ifeq ($(BR2_PACKAGE_LIBPCAP),y)
104 +DPDK_DEPENDENCIES += libpcap
105 +endif
106 +
107 +ifeq ($(BR2_SHARED_LIBS),y)
108 +define DPDK_ENABLE_SHARED_LIBS
109 +       $(call KCONFIG_ENABLE_OPT,CONFIG_RTE_BUILD_SHARED_LIB,\
110 +                       $(@D)/build/.config)
111 +endef
112 +
113 +DPDK_POST_CONFIGURE_HOOKS += DPDK_ENABLE_SHARED_LIBS
114 +endif
115 +
116 +# We're building a kernel module without using the kernel-module infra,
117 +# so we need to tell we want module support in the kernel
118 +ifeq ($(BR2_PACKAGE_DPDK),y)
119 +LINUX_NEEDS_MODULES = y
120 +endif
121 +
122 +DPDK_CONFIG = $(call qstrip,$(BR2_PACKAGE_DPDK_CONFIG))
123 +
124 +ifeq ($(BR2_PACKAGE_DPDK_EXAMPLES),y)
125 +# Build of DPDK examples is not very straight-forward. It requires to have
126 +# the SDK and runtime installed on same place to reference it by RTE_SDK.
127 +# We place it locally in the build directory.
128 +# In additition, some examples seem to have a dependency on the ethtool
129 +# example that may not be met when building in parallel for the first
130 +# time. As a (dirty) workaround, we build twice.
131 +define DPDK_BUILD_EXAMPLES
132 +       $(MAKE) -C $(@D) DESTDIR=$(@D)/examples-sdk \
133 +               CROSS=$(TARGET_CROSS) install-sdk install-runtime
134 +       $(MAKE) -C $(@D) RTE_KERNELDIR=$(LINUX_DIR) CROSS=$(TARGET_CROSS) \
135 +               RTE_SDK=$(@D)/examples-sdk/usr/local/share/dpdk \
136 +               T=$(DPDK_CONFIG) examples || echo "Failed, building again"
137 +       $(MAKE) -C $(@D) RTE_KERNELDIR=$(LINUX_DIR) CROSS=$(TARGET_CROSS) \
138 +               RTE_SDK=$(@D)/examples-sdk/usr/local/share/dpdk \
139 +               T=$(DPDK_CONFIG) examples
140 +endef
141 +
142 +DPDK_EXAMPLES_PATH = $(@D)/examples-sdk/usr/local/share/dpdk/examples
143 +
144 +# Installation of examples is not supported in DPDK so we do it explicitly
145 +# here. As the binaries and libraries do not have a single or regular location
146 +# where to find them after build, we search for them by find.
147 +define DPDK_INSTALL_EXAMPLES
148 +       $(INSTALL) -m 0755 -d $(TARGET_DIR)/usr/local/bin
149 +       $(INSTALL) -m 0755 -d $(TARGET_DIR)/usr/local/lib
150 +       for f in `find $(DPDK_EXAMPLES_PATH) -executable -type f   \
151 +                       -name '[a-z]*.so*' | grep '\/lib\/.*'`; do \
152 +               $(INSTALL) -m 0755 -D $$f                          \
153 +                       $(TARGET_DIR)/usr/local/lib/`basename $$f`;\
154 +       done
155 +       for f in `find $(DPDK_EXAMPLES_PATH) -executable -type f   \
156 +                       ! -name '*.so*' | grep '\/app\/.*'`; do    \
157 +               $(INSTALL) -m 0755 -D $$f                          \
158 +                       $(TARGET_DIR)/usr/local/bin/`basename $$f`;\
159 +       done
160 +endef
161 +
162 +define DPDK_INSTALL_KMOD
163 +       $(INSTALL) -m 0755 -d $(TARGET_DIR)/usr/local/kmod
164 +       for f in `find $(@D)/build/kmod -name '*.ko'` ; do              \
165 +               $(INSTALL) -m 0755 -D $$f                               \
166 +                       $(TARGET_DIR)/usr/local/kmod/`basename $$f`;    \
167 +       done
168 +endef
169 +
170 +# Build of the power example is broken (at least for 16.04).
171 +define DPDK_DISABLE_POWER
172 +       $(call KCONFIG_DISABLE_OPT,CONFIG_RTE_LIBRTE_POWER,\
173 +                       $(@D)/build/.config)
174 +endef
175 +
176 +DPDK_POST_CONFIGURE_HOOKS += DPDK_DISABLE_POWER
177 +endif
178 +
179 +define DPDK_CONFIGURE_CMDS
180 +       $(MAKE) -C $(@D) T=$(DPDK_CONFIG) RTE_KERNELDIR=$(LINUX_DIR) \
181 +                          CROSS=$(TARGET_CROSS) config
182 +endef
183 +
184 +define DPDK_BUILD_CMDS
185 +        $(TARGET_MAKE_ENV) LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) \
186 +                DBM_INCLUDE="$(STAGING_DIR)/usr/include" \
187 +                CCOPTS="$(TARGET_CFLAGS) -D_GNU_SOURCE" \
188 +                SHARED_LIBS="$(if $(BR2_STATIC_LIBS),n,y)" -C $(@D) \
189 +                RTE_KERNELDIR=$(LINUX_DIR) CROSS=$(TARGET_CROSS)
190 +       $(DPDK_BUILD_EXAMPLES)
191 +endef
192 +
193 +define DPDK_INSTALL_STAGING_CMDS
194 +       $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) prefix=/usr \
195 +                CROSS=$(TARGET_CROSS) install-sdk
196 +endef
197 +
198 +ifeq ($(BR2_PACKAGE_DPDK_TEST),y)
199 +define DPDK_INSTALL_TARGET_TEST
200 +       $(INSTALL) -m 0755 -d $(TARGET_DIR)/usr/dpdk
201 +       $(INSTALL) -m 0755 -D $(@D)/build/app/test $(TARGET_DIR)/usr/dpdk
202 +       $(INSTALL) -m 0755 -D $(@D)/app/test/*.py $(TARGET_DIR)/usr/dpdk
203 +endef
204 +endif
205 +
206 +define DPDK_INSTALL_TARGET_CMDS
207 +       $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) prefix=/usr \
208 +               CROSS=$(TARGET_CROSS) install-runtime
209 +        $(DPDK_INSTALL_KMOD)
210 +       $(DPDK_INSTALL_TARGET_TEST)
211 +       $(DPDK_INSTALL_EXAMPLES)
212 +endef
213 +
214 +$(eval $(generic-package))