1 # Copyright (c) 2015 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 # Scripts require non-POSIX parts of bash
17 DPDK_BUILD_DIR ?= $(CURDIR)/_build
18 DPDK_INSTALL_DIR ?= $(CURDIR)/_install
19 DPDK_PKTMBUF_HEADROOM ?= 128
20 DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads
22 DPDK_CRYPTO_SW_PMD ?= n
25 B := $(DPDK_BUILD_DIR)
26 I := $(DPDK_INSTALL_DIR)
29 DPDK_BASE_URL ?= http://fast.dpdk.org/rel
30 DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
31 DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
32 DPDK_16.07_TARBALL_MD5_CKSUM := 690a2bb570103e58d12f9806e8bf21be
33 DPDK_16.11_TARBALL_MD5_CKSUM := 06c1c577795360719d0b4fafaeee21e9
34 DPDK_17.02_TARBALL_MD5_CKSUM := 6b9f7387c35641f4e8dbba3e528f2376
35 DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
37 ifeq ($(DPDK_CRYPTO_SW_PMD),y)
38 AESNIMB_LIB_TARBALL := v0.44.tar.gz
39 AESNIMB_LIB_TARBALL_URL := http://github.com/01org/intel-ipsec-mb/archive/$(AESNIMB_LIB_TARBALL)
40 AESNIMB_LIB_SOURCE := $(B)/intel-ipsec-mb-0.44
41 ISA_L_CRYPTO_LIB_TARBALL := isa_l_crypto.tar.gz
42 ISA_L_CRYPTO_LIB_TARBALL_URL := http://github.com/01org/isa-l_crypto/archive/master.tar.gz
43 ISA_L_CRYPTO_LIB_SOURCE := $(B)/isa-l_crypto-master
46 ifneq (,$(findstring clang,$(CC)))
48 else ifneq (,$(findstring icc,$(CC)))
54 ##############################################################################
56 ##############################################################################
57 ifeq ($(shell uname -m),x86_64)
58 DPDK_TARGET ?= x86_64-native-linuxapp-$(DPDK_CC)
60 DPDK_TUNE ?= core-avx2
62 ##############################################################################
64 ##############################################################################
65 else ifneq (,$(findstring thunder,$(shell cat /sys/bus/pci/devices/0000:00:01.0/uevent | grep cavium)))
67 DPDK_TARGET ?= arm64-thunderx-linuxapp-$(DPDK_CC)
68 DPDK_MACHINE ?= thunderx
71 ##############################################################################
73 ##############################################################################
75 $(error unknown platform)
78 JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
80 # compiler/linker custom arguments
81 DPDK_CPU_CFLAGS := -pie -fPIC
82 DPDK_EXTRA_LDFLAGS := -g
84 ifeq ($(DPDK_DEBUG),n)
85 DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
87 DPDK_EXTRA_CFLAGS := -g -O0
90 ifeq ($(DPDK_CRYPTO_SW_PMD),y)
91 DPDK_EXTRA_CFLAGS += -I$(ISA_L_CRYPTO_LIB_SOURCE)
92 DPDK_EXTRA_LDFLAGS += -L$(ISA_L_CRYPTO_LIB_SOURCE)/.libs
93 DPDK_MAKE_EXTRA_ARGS += AESNI_MULTI_BUFFER_LIB_PATH=$(AESNIMB_LIB_SOURCE)
96 # assemble DPDK make arguments
97 DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
99 RTE_CONFIG_TEMPLATE=../custom-config \
100 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
101 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
102 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
104 $(DPDK_MAKE_EXTRA_ARGS)
106 DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
109 @if grep -q CONFIG_$1 $@ ; \
110 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
111 else echo CONFIG_$1=$2 >> $@ ; \
117 $(B)/custom-config: $(B)/.patch.ok Makefile
118 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
119 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
120 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
122 $(call set,RTE_MAX_LCORE,256)
123 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
124 $(call set,RTE_LIBEAL_USE_HPET,y)
125 $(call set,RTE_BUILD_COMBINE_LIBS,y)
126 $(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y)
127 $(call set,RTE_PCI_CONFIG,y)
128 $(call set,RTE_PCI_EXTENDED_TAG,"on")
129 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
130 @# enable debug init for device drivers
131 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
132 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
133 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
134 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
135 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
136 $(call set,RTE_LIBRTE_PMD_BOND,y)
137 $(call set,RTE_LIBRTE_IP_FRAG,y)
138 $(call set,RTE_LIBRTE_PMD_QAT,y)
139 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(DPDK_CRYPTO_SW_PMD))
140 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(DPDK_CRYPTO_SW_PMD))
141 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
143 $(call set,RTE_LIBRTE_TIMER,n)
144 $(call set,RTE_LIBRTE_CFGFILE,n)
145 $(call set,RTE_LIBRTE_LPM,n)
146 $(call set,RTE_LIBRTE_ACL,n)
147 $(call set,RTE_LIBRTE_POWER,n)
148 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
149 $(call set,RTE_LIBRTE_REORDER,n)
150 $(call set,RTE_LIBRTE_PORT,n)
151 $(call set,RTE_LIBRTE_TABLE,n)
152 $(call set,RTE_LIBRTE_PIPELINE,n)
153 $(call set,RTE_KNI_KMOD,n)
154 $(call set,RTE_EAL_IGB_UIO,n)
157 $(CURDIR)/$(DPDK_TARBALL):
158 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
159 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
160 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
162 ifeq ($(DPDK_CRYPTO_SW_PMD),y)
163 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) ] ; \
164 then cp $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) $(CURDIR) ; \
165 else curl -o $(CURDIR)/$(AESNIMB_LIB_TARBALL) -LO $(AESNIMB_LIB_TARBALL_URL) ; \
167 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) ] ; \
168 then cp $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) $(CURDIR) ; \
169 else curl -o $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL) -LO $(ISA_L_CRYPTO_LIB_TARBALL_URL) ; \
172 @rm -f $(B)/.download.ok
174 $(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL)
176 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
177 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
178 ( echo "Bad Checksum! Please remove $< and retry" && \
179 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
183 download: $(B)/.download.ok
185 $(B)/.extract.ok: $(B)/.download.ok
186 @echo --- extracting $(DPDK_TARBALL) ---
187 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
188 ifeq ($(DPDK_CRYPTO_SW_PMD),y)
189 @echo --- extracting $(AESNIMB_LIB_TARBALL) ---
190 @tar --directory $(B) --extract --file $(CURDIR)/$(AESNIMB_LIB_TARBALL)
191 @echo --- extracting $(ISA_L_CRYPTO_LIB_TARBALL) ---
192 @tar --directory $(B) --extract --file $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
197 extract: $(B)/.extract.ok
199 $(B)/.patch.ok: $(B)/.extract.ok
200 ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
201 @echo --- patching ---
202 @for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
203 echo Applying patch: $$(basename $$f) ; \
204 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
210 patch: $(B)/.patch.ok
212 $(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
213 ifeq ($(DPDK_CRYPTO_SW_PMD),y)
214 @make -C $(AESNIMB_LIB_SOURCE)
215 @cd $(ISA_L_CRYPTO_LIB_SOURCE) && ./autogen.sh && ./configure
216 @make -C $(ISA_L_CRYPTO_LIB_SOURCE)
217 @cp $(ISA_L_CRYPTO_LIB_SOURCE)/include $(ISA_L_CRYPTO_LIB_SOURCE)/isa-l_crypto -r
219 @make $(DPDK_MAKE_ARGS) config
223 config: $(B)/.config.ok
225 $(B)/.build.ok: $(DPDK_SOURCE_FILES)
226 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
227 @make $(DPDK_MAKE_ARGS) install
228 ifeq ($(DPDK_CRYPTO_SW_PMD),y)
229 @cp $(AESNIMB_LIB_SOURCE)/libIPSec_MB.a $(I)/lib/
230 @cp $(ISA_L_CRYPTO_LIB_SOURCE)/.libs/libisal_crypto.a $(I)/lib/
235 build: $(B)/.build.ok
238 install: $(B)/.build.ok
244 ##############################################################################
246 ##############################################################################
248 DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
249 DEV_DEB=vpp-dpdk-dev_$(DPDK_VERSION)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
250 INSTALLED_DEB_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-dpdk-dev 2> /dev/null)
252 .PHONY: build-deb install-deb check-deb
254 deb/debian/changelog: Makefile
255 @echo "vpp-dpdk ($(DPDK_VERSION)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
257 @echo " * DPDK Release $(DPDK_VERSION)" >> $@
259 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
261 $(DEV_DEB): deb/debian/changelog
262 @cd deb && dpkg-buildpackage -b -uc -us
265 build-deb: $(DEV_DEB)
268 ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
270 @sudo dpkg -i $(DEV_DEB)
272 @echo "=========================================================="
273 @echo " Up-to-date DPDK package already installed"
274 @echo "=========================================================="
278 ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
279 @echo "=========================================================="
280 @echo " Outdated DPDK package detected:"
281 @echo " Installed: vpp-dpdk-dev $(INSTALLED_DEB_VER)"
282 @echo " Current: vpp-dpdk-dev $(DPDK_VERSION)-$(PKG_SUFFIX)"
284 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
285 @echo " from the top level directory."
286 @echo "=========================================================="
289 ##############################################################################
291 ##############################################################################
293 RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
294 DEV_RPM=vpp-dpdk-devel-$(DPDK_VERSION)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
295 INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-dpdk-devel 2> /dev/null | grep -v "not inst")
297 .PHONY: build-rpm install-rpm check-rpm
299 $(DEV_RPM): Makefile rpm/vpp-dpdk.spec
301 --define "_topdir $(CURDIR)/rpm" \
302 --define "_version $(DPDK_VERSION)" \
303 --define "_release $(PKG_SUFFIX)" \
304 $(CURDIR)/rpm/vpp-dpdk.spec
305 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
308 build-rpm: $(DEV_RPM)
311 ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
313 sudo rpm -Uih $(DEV_RPM)
315 @echo "=========================================================="
316 @echo " Up-to-date DPDK package already installed"
317 @echo "=========================================================="
321 ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
322 @echo "=========================================================="
323 @echo " Outdated DPDK package detected:"
324 @echo " Installed: vpp-dpdk-devel $(INSTALLED_RPM_VER)"
325 @echo " Current: vpp-dpdk-devel $(DPDK_VERSION)-$(PKG_SUFFIX)"
327 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
328 @echo " from the top level directory."
329 @echo "=========================================================="
332 ##############################################################################
334 ##############################################################################
336 .PHONY: ebuild-build ebuild-install
339 ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
340 @echo "=========================================================="
341 @echo "Building DPDK from source. Consider installing development"
342 @echo "package by invoking 'make dpdk-install-dev' from the"
343 @echo "top level directory"
344 @echo "=========================================================="
347 ifneq ($(INSTALLED_DEB_VER),)
350 ifneq ($(INSTALLED_RPM_VER),)
356 ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)