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