blob: f8c85c967dc66a720582e09420db535588146867 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001# 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:
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
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.
13
14# Scripts require non-POSIX parts of bash
15SHELL := /bin/bash
16
17DPDK_BUILD_DIR ?= $(CURDIR)/_build
18DPDK_INSTALL_DIR ?= $(CURDIR)/_install
Damjan Marion19010202016-03-24 17:17:47 +010019DPDK_PKTMBUF_HEADROOM ?= 128
Ed Warnickecb9cada2015-12-08 15:45:58 -070020DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads
Ed Warnickecb9cada2015-12-08 15:45:58 -070021DPDK_DEBUG ?= n
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +000022DPDK_CRYPTO_SW_PMD ?= n
Damjan Marion696f1ad2016-12-23 22:42:41 +010023DPDK_MLX5_PMD ?= n
Ed Warnickecb9cada2015-12-08 15:45:58 -070024
25B := $(DPDK_BUILD_DIR)
26I := $(DPDK_INSTALL_DIR)
Damjan Marion4983e472017-02-16 20:28:35 +010027DPDK_VERSION ?= 17.02
28PKG_SUFFIX ?= vpp1
Thomas Monjalon96e10b52016-06-02 14:52:32 +020029DPDK_BASE_URL ?= http://fast.dpdk.org/rel
30DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
Damjan Mariondab123b2016-03-29 16:43:58 +020031DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Sachin734d2912016-08-02 11:35:48 +053032DPDK_16.07_TARBALL_MD5_CKSUM := 690a2bb570103e58d12f9806e8bf21be
Damjan Mariond4895d52016-11-14 21:45:20 +010033DPDK_16.11_TARBALL_MD5_CKSUM := 06c1c577795360719d0b4fafaeee21e9
Damjan Marion4983e472017-02-16 20:28:35 +010034DPDK_17.02_TARBALL_MD5_CKSUM := 6b9f7387c35641f4e8dbba3e528f2376
Ed Warnickecb9cada2015-12-08 15:45:58 -070035DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
Radu Nicolau2e3677b2017-02-20 12:27:02 +000036
Radu Nicolau6ca42d32017-02-16 13:54:42 +000037ifeq ($(DPDK_CRYPTO_SW_PMD),y)
38AESNIMB_LIB_TARBALL := v0.44.tar.gz
39AESNIMB_LIB_TARBALL_URL := http://github.com/01org/intel-ipsec-mb/archive/$(AESNIMB_LIB_TARBALL)
40AESNIMB_LIB_SOURCE := $(B)/intel-ipsec-mb-0.44
Radu Nicolau2e3677b2017-02-20 12:27:02 +000041ISA_L_CRYPTO_LIB_TARBALL := isa_l_crypto.tar.gz
42ISA_L_CRYPTO_LIB_TARBALL_URL := http://github.com/01org/isa-l_crypto/archive/master.tar.gz
43ISA_L_CRYPTO_LIB_SOURCE := $(B)/isa-l_crypto-master
Radu Nicolau6ca42d32017-02-16 13:54:42 +000044endif
Damjan Marione39a7b82016-04-26 14:54:57 +020045
46ifneq (,$(findstring clang,$(CC)))
47DPDK_CC=clang
Damjan Marion78edb8e2017-02-06 22:28:52 +010048else ifneq (,$(findstring icc,$(CC)))
49DPDK_CC=icc
Damjan Marione39a7b82016-04-26 14:54:57 +020050else
51DPDK_CC=gcc
52endif
53
Damjan Marion78edb8e2017-02-06 22:28:52 +010054##############################################################################
55# Intel x86_64
56##############################################################################
57ifeq ($(shell uname -m),x86_64)
58DPDK_TARGET ?= x86_64-native-linuxapp-$(DPDK_CC)
59DPDK_MACHINE ?= nhm
60DPDK_TUNE ?= core-avx2
Christophe Fontaine737547e2016-05-11 08:40:33 +000061
Damjan Marion78edb8e2017-02-06 22:28:52 +010062##############################################################################
63# Cavium ThunderX
64##############################################################################
65else ifneq (,$(findstring thunder,$(shell cat /sys/bus/pci/devices/0000:00:01.0/uevent | grep cavium)))
66export CROSS=""
67DPDK_TARGET ?= arm64-thunderx-linuxapp-$(DPDK_CC)
68DPDK_MACHINE ?= thunderx
69DPDK_TUNE ?= generic
70
71##############################################################################
72# Unknown platofrm
73##############################################################################
74else
75$(error unknown platform)
Christophe Fontaine737547e2016-05-11 08:40:33 +000076endif
77
Ed Warnickecb9cada2015-12-08 15:45:58 -070078JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
79
80# compiler/linker custom arguments
81DPDK_CPU_CFLAGS := -pie -fPIC
Ed Warnickecb9cada2015-12-08 15:45:58 -070082DPDK_EXTRA_LDFLAGS := -g
83
84ifeq ($(DPDK_DEBUG),n)
Damjan Marion1c80e832016-05-11 23:07:18 +020085DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
Ed Warnickecb9cada2015-12-08 15:45:58 -070086else
Damjan Marione39a7b82016-04-26 14:54:57 +020087DPDK_EXTRA_CFLAGS := -g -O0
Ed Warnickecb9cada2015-12-08 15:45:58 -070088endif
89
Radu Nicolau2e3677b2017-02-20 12:27:02 +000090ifeq ($(DPDK_CRYPTO_SW_PMD),y)
91DPDK_EXTRA_CFLAGS += -I$(ISA_L_CRYPTO_LIB_SOURCE)
92DPDK_EXTRA_LDFLAGS += -L$(ISA_L_CRYPTO_LIB_SOURCE)/.libs
93DPDK_MAKE_EXTRA_ARGS += AESNI_MULTI_BUFFER_LIB_PATH=$(AESNIMB_LIB_SOURCE)
94endif
95
Ed Warnickecb9cada2015-12-08 15:45:58 -070096# assemble DPDK make arguments
97DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
98 T=$(DPDK_TARGET) \
99 RTE_CONFIG_TEMPLATE=../custom-config \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700100 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
101 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
102 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100103 DESTDIR=$(I) \
Christophe Fontaine737547e2016-05-11 08:40:33 +0000104 $(DPDK_MAKE_EXTRA_ARGS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700105
Damjan Marion78edb8e2017-02-06 22:28:52 +0100106DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
Ed Warnickecb9cada2015-12-08 15:45:58 -0700107
108define set
109@if grep -q CONFIG_$1 $@ ; \
110 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
111 else echo CONFIG_$1=$2 >> $@ ; \
112fi
113endef
114
115all: build
116
117$(B)/custom-config: $(B)/.patch.ok Makefile
Damjan Marion106f0ed2016-04-26 10:44:28 +0200118 @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) $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700120 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700121 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -0800122 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700123 $(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)
Damjan Mariona1556802016-06-26 20:12:40 +0200127 $(call set,RTE_PCI_CONFIG,y)
128 $(call set,RTE_PCI_EXTENDED_TAG,"on")
129 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700130 @# 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))
John Lod9bf9ab2016-02-25 11:17:55 -0500136 $(call set,RTE_LIBRTE_PMD_BOND,y)
137 $(call set,RTE_LIBRTE_IP_FRAG,y)
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000138 $(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))
Damjan Marion696f1ad2016-12-23 22:42:41 +0100141 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700142 @# not needed
Ed Warnickecb9cada2015-12-08 15:45:58 -0700143 $(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)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700148 $(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)
Damjan Marion68fda1c2017-01-01 16:53:22 +0100154 $(call set,RTE_EAL_IGB_UIO,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700155 @rm -f .config.ok
156
157$(CURDIR)/$(DPDK_TARBALL):
Ed Warnickecb9cada2015-12-08 15:45:58 -0700158 @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) ; \
161 fi
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000162ifeq ($(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) ; \
166 fi
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000167 @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) ; \
170 fi
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000171endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700172 @rm -f $(B)/.download.ok
173
174$(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100175 @mkdir -p $(B)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700176 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100177 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700178 ( echo "Bad Checksum! Please remove $< and retry" && \
179 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
180 @touch $@
181
182.PHONY: download
183download: $(B)/.download.ok
184
185$(B)/.extract.ok: $(B)/.download.ok
186 @echo --- extracting $(DPDK_TARBALL) ---
Thomas Monjalon96e10b52016-06-02 14:52:32 +0200187 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000188ifeq ($(DPDK_CRYPTO_SW_PMD),y)
189 @echo --- extracting $(AESNIMB_LIB_TARBALL) ---
190 @tar --directory $(B) --extract --file $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000191 @echo --- extracting $(ISA_L_CRYPTO_LIB_TARBALL) ---
192 @tar --directory $(B) --extract --file $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000193endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700194 @touch $@
195
196.PHONY: extract
197extract: $(B)/.extract.ok
198
199$(B)/.patch.ok: $(B)/.extract.ok
Damjan Marion0df78dd2016-03-29 22:37:02 +0200200ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700201 @echo --- patching ---
Damjan Marion2ce7f982017-01-09 20:24:50 +0100202 @for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700203 echo Applying patch: $$(basename $$f) ; \
204 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
205 done
Damjan Marion0df78dd2016-03-29 22:37:02 +0200206endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700207 @touch $@
208
209.PHONY: patch
210patch: $(B)/.patch.ok
211
212$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000213ifeq ($(DPDK_CRYPTO_SW_PMD),y)
214 @make -C $(AESNIMB_LIB_SOURCE)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000215 @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
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000218endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700219 @make $(DPDK_MAKE_ARGS) config
220 @touch $@
221
222.PHONY: config
223config: $(B)/.config.ok
224
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
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000228ifeq ($(DPDK_CRYPTO_SW_PMD),y)
229 @cp $(AESNIMB_LIB_SOURCE)/libIPSec_MB.a $(I)/lib/
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000230 @cp $(ISA_L_CRYPTO_LIB_SOURCE)/.libs/libisal_crypto.a $(I)/lib/
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000231endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700232 @touch $@
233
234.PHONY: build
235build: $(B)/.build.ok
236
Damjan Marion2ce7f982017-01-09 20:24:50 +0100237.PHONY: install
238install: $(B)/.build.ok
239
Ed Warnickecb9cada2015-12-08 15:45:58 -0700240.PHONY: clean
241clean:
242 @rm -rf $(B) $(I)
243
Damjan Marion2ce7f982017-01-09 20:24:50 +0100244##############################################################################
245# .deb packaging
246##############################################################################
247
248DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
249DEV_DEB=vpp-dpdk-dev_$(DPDK_VERSION)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
250INSTALLED_DEB_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-dpdk-dev 2> /dev/null)
251
252.PHONY: build-deb install-deb check-deb
253
254deb/debian/changelog: Makefile
255 @echo "vpp-dpdk ($(DPDK_VERSION)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
256 @echo "" >> $@
257 @echo " * DPDK Release $(DPDK_VERSION)" >> $@
258 @echo "" >> $@
259 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
260
261$(DEV_DEB): deb/debian/changelog
262 @cd deb && dpkg-buildpackage -b -uc -us
263 git clean -fdx deb
264
265build-deb: $(DEV_DEB)
266
267install-deb:
268ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
269 @make $(DEV_DEB)
270 @sudo dpkg -i $(DEV_DEB)
271else
272 @echo "=========================================================="
273 @echo " Up-to-date DPDK package already installed"
274 @echo "=========================================================="
275endif
276
277check-deb:
278ifneq ($(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)"
283 @echo ""
284 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
285 @echo " from the top level directory."
286 @echo "=========================================================="
287endif
288
289##############################################################################
290# .rpm packaging
291##############################################################################
292
293RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
294DEV_RPM=vpp-dpdk-devel-$(DPDK_VERSION)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
Damjan Marion248968b2017-01-20 23:59:28 +0100295INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-dpdk-devel 2> /dev/null | grep -v "not inst")
Damjan Marion2ce7f982017-01-09 20:24:50 +0100296
297.PHONY: build-rpm install-rpm check-rpm
298
299$(DEV_RPM): Makefile rpm/vpp-dpdk.spec
300 @rpmbuild -bb \
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 .
306 git clean -fdx rpm
307
308build-rpm: $(DEV_RPM)
309
310install-rpm:
311ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
312 @make $(DEV_RPM)
313 sudo rpm -Uih $(DEV_RPM)
314else
315 @echo "=========================================================="
316 @echo " Up-to-date DPDK package already installed"
317 @echo "=========================================================="
318endif
319
320check-rpm:
321ifneq ($(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)"
326 @echo ""
327 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
328 @echo " from the top level directory."
329 @echo "=========================================================="
330endif
331
332##############################################################################
333# ebuild support
334##############################################################################
335
336.PHONY: ebuild-build ebuild-install
337
338ebuild-build:
339ifeq ($(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 "=========================================================="
345 make config
346else
347ifneq ($(INSTALLED_DEB_VER),)
348 make check-deb
349endif
350ifneq ($(INSTALLED_RPM_VER),)
351 make check-rpm
352endif
353endif
354
355ebuild-install:
356ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
357 make install
358endif