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
27 B := $(DPDK_BUILD_DIR)
28 I := $(DPDK_INSTALL_DIR)
31 DPDK_BASE_URL ?= http://fast.dpdk.org/rel
32 DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
33 DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
34 DPDK_16.07_TARBALL_MD5_CKSUM := 690a2bb570103e58d12f9806e8bf21be
35 DPDK_16.11_TARBALL_MD5_CKSUM := 06c1c577795360719d0b4fafaeee21e9
36 DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
38 ifneq (,$(findstring clang,$(CC)))
45 ifeq (,$(DPDK_TARGET))
46 DPDK_TARGET := x86_64-native-linuxapp-$(DPDK_CC)
49 JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
51 # compiler/linker custom arguments
52 DPDK_CPU_CFLAGS := -pie -fPIC
54 DPDK_EXTRA_LDFLAGS := -g
56 ifeq ($(DPDK_DEBUG),n)
57 DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
59 DPDK_EXTRA_CFLAGS := -g -O0
62 # translate gcc march values to DPDK arch
63 ifeq ($(DPDK_MARCH),native)
64 DPDK_MACHINE:=native # autodetect host CPU
65 else ifeq ($(DPDK_MARCH),corei7)
66 DPDK_MACHINE:=nhm # Nehalem / Westmere
67 else ifeq ($(DPDK_MARCH),corei7-avx)
68 DPDK_MACHINE:=snb # Sandy Bridge
69 else ifeq ($(DPDK_MARCH),core-avx-i)
70 DPDK_MACHINE:=ivb # Ivy Bridge
71 else ifeq ($(DPDK_MARCH),core-avx2)
72 DPDK_MACHINE:=hsw # Haswell
73 else ifeq ($(DPDK_MARCH),armv7a)
74 DPDK_MACHINE:=armv7a # ARMv7
75 else ifeq ($(DPDK_MARCH),armv8a)
76 DPDK_MACHINE:=armv8a # ARMv8
78 $(error Unknown DPDK_MARCH)
81 # assemble DPDK make arguments
82 DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
84 RTE_CONFIG_TEMPLATE=../custom-config \
85 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
86 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
87 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
88 CPU_LDFLAGS="$(DPDK_CPU_LDFLAGS)" \
90 $(DPDK_MAKE_EXTRA_ARGS)
92 DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
95 @if grep -q CONFIG_$1 $@ ; \
96 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
97 else echo CONFIG_$1=$2 >> $@ ; \
103 $(B)/custom-config: $(B)/.patch.ok Makefile
104 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
105 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
106 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
108 $(call set,RTE_MAX_LCORE,256)
109 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
110 $(call set,RTE_LIBEAL_USE_HPET,y)
111 $(call set,RTE_BUILD_COMBINE_LIBS,y)
112 $(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y)
113 $(call set,RTE_PCI_CONFIG,y)
114 $(call set,RTE_PCI_EXTENDED_TAG,"on")
115 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
116 @# enable debug init for device drivers
117 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
118 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
119 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
120 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
121 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
122 $(call set,RTE_LIBRTE_PMD_BOND,y)
123 $(call set,RTE_LIBRTE_IP_FRAG,y)
124 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(DPDK_CRYPTO_PMD))
125 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(DPDK_CRYPTO_PMD))
126 $(call set,RTE_LIBRTE_PMD_QAT,$(DPDK_CRYPTO_PMD))
127 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
129 $(call set,RTE_LIBRTE_TIMER,n)
130 $(call set,RTE_LIBRTE_CFGFILE,n)
131 $(call set,RTE_LIBRTE_LPM,n)
132 $(call set,RTE_LIBRTE_ACL,n)
133 $(call set,RTE_LIBRTE_POWER,n)
134 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
135 $(call set,RTE_LIBRTE_REORDER,n)
136 $(call set,RTE_LIBRTE_PORT,n)
137 $(call set,RTE_LIBRTE_TABLE,n)
138 $(call set,RTE_LIBRTE_PIPELINE,n)
139 $(call set,RTE_KNI_KMOD,n)
140 $(call set,RTE_EAL_IGB_UIO,n)
143 $(CURDIR)/$(DPDK_TARBALL):
144 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
145 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
146 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
148 @rm -f $(B)/.download.ok
150 $(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL)
152 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
153 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
154 ( echo "Bad Checksum! Please remove $< and retry" && \
155 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
159 download: $(B)/.download.ok
161 $(B)/.extract.ok: $(B)/.download.ok
162 @echo --- extracting $(DPDK_TARBALL) ---
163 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
167 extract: $(B)/.extract.ok
169 $(B)/.patch.ok: $(B)/.extract.ok
170 ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
171 @echo --- patching ---
172 @for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
173 echo Applying patch: $$(basename $$f) ; \
174 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
180 patch: $(B)/.patch.ok
182 $(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
183 @make $(DPDK_MAKE_ARGS) config
187 config: $(B)/.config.ok
189 $(B)/.build.ok: $(DPDK_SOURCE_FILES)
190 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
191 @make $(DPDK_MAKE_ARGS) install
195 build: $(B)/.build.ok
198 install: $(B)/.build.ok
204 ##############################################################################
206 ##############################################################################
208 DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
209 DEV_DEB=vpp-dpdk-dev_$(DPDK_VERSION)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
210 INSTALLED_DEB_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-dpdk-dev 2> /dev/null)
212 .PHONY: build-deb install-deb check-deb
214 deb/debian/changelog: Makefile
215 @echo "vpp-dpdk ($(DPDK_VERSION)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
217 @echo " * DPDK Release $(DPDK_VERSION)" >> $@
219 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
221 $(DEV_DEB): deb/debian/changelog
222 @cd deb && dpkg-buildpackage -b -uc -us
225 build-deb: $(DEV_DEB)
228 ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
230 @sudo dpkg -i $(DEV_DEB)
232 @echo "=========================================================="
233 @echo " Up-to-date DPDK package already installed"
234 @echo "=========================================================="
238 ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
239 @echo "=========================================================="
240 @echo " Outdated DPDK package detected:"
241 @echo " Installed: vpp-dpdk-dev $(INSTALLED_DEB_VER)"
242 @echo " Current: vpp-dpdk-dev $(DPDK_VERSION)-$(PKG_SUFFIX)"
244 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
245 @echo " from the top level directory."
246 @echo "=========================================================="
249 ##############################################################################
251 ##############################################################################
253 RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
254 DEV_RPM=vpp-dpdk-devel-$(DPDK_VERSION)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
255 INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-dpdk-devel 2> /dev/null | grep -v "not inst")
257 .PHONY: build-rpm install-rpm check-rpm
259 $(DEV_RPM): Makefile rpm/vpp-dpdk.spec
261 --define "_topdir $(CURDIR)/rpm" \
262 --define "_version $(DPDK_VERSION)" \
263 --define "_release $(PKG_SUFFIX)" \
264 $(CURDIR)/rpm/vpp-dpdk.spec
265 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
268 build-rpm: $(DEV_RPM)
271 ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
273 sudo rpm -Uih $(DEV_RPM)
275 @echo "=========================================================="
276 @echo " Up-to-date DPDK package already installed"
277 @echo "=========================================================="
281 ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
282 @echo "=========================================================="
283 @echo " Outdated DPDK package detected:"
284 @echo " Installed: vpp-dpdk-devel $(INSTALLED_RPM_VER)"
285 @echo " Current: vpp-dpdk-devel $(DPDK_VERSION)-$(PKG_SUFFIX)"
287 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
288 @echo " from the top level directory."
289 @echo "=========================================================="
292 ##############################################################################
294 ##############################################################################
296 .PHONY: ebuild-build ebuild-install
299 ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
300 @echo "=========================================================="
301 @echo "Building DPDK from source. Consider installing development"
302 @echo "package by invoking 'make dpdk-install-dev' from the"
303 @echo "top level directory"
304 @echo "=========================================================="
307 ifneq ($(INSTALLED_DEB_VER),)
310 ifneq ($(INSTALLED_RPM_VER),)
316 ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)