blob: a551151bba712e6c865b0792a37d84c82f251d03 [file] [log] [blame]
Damjan Marion561f2732018-09-21 12:27:45 +02001# Copyright (c) 2018 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
14DPDK_PKTMBUF_HEADROOM ?= 128
15DPDK_CACHE_LINE_SIZE ?= 64
16DPDK_DOWNLOAD_DIR ?= $(DL_CACHE_DIR)
17DPDK_DEBUG ?= n
18DPDK_MLX4_PMD ?= n
19DPDK_MLX5_PMD ?= n
20DPDK_TAP_PMD ?= n
21DPDK_FAILSAFE_PMD ?= n
22
Damjan Marion1a6ece32019-02-02 16:28:16 +010023DPDK_VERSION ?= 19.02
Damjan Marion561f2732018-09-21 12:27:45 +020024DPDK_BASE_URL ?= http://fast.dpdk.org/rel
25DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
26DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Damjan Marion14033aa2018-11-27 12:18:26 +010027DPDK_18.11_TARBALL_MD5_CKSUM := 04b86f4a77f4f81a7fbd26467dd2ea9f
Damjan Marion1a6ece32019-02-02 16:28:16 +010028DPDK_19.02_TARBALL_MD5_CKSUM := 23944a2cdee061aa4bd72ebe7d836db0
Damjan Marion561f2732018-09-21 12:27:45 +020029MACHINE=$(shell uname -m)
30
31# replace dot with space, and if 3rd word exists we deal with stable dpdk rel
32ifeq ($(word 3,$(subst ., ,$(DPDK_VERSION))),)
33DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
34else
35DPDK_SOURCE := $(B)/dpdk-stable-$(DPDK_VERSION)
36endif
37
38ifeq ($(MACHINE),$(filter $(MACHINE),x86_64))
39 AESNI ?= y
40 DPDK_BUILD_DEPS := ipsec-mb-install
41else
42 AESNI ?= n
43endif
44
45ifneq (,$(findstring clang,$(CC)))
46DPDK_CC=clang
47else ifneq (,$(findstring icc,$(CC)))
48DPDK_CC=icc
49else
50DPDK_CC=gcc
51endif
52
53##############################################################################
54# Intel x86
55##############################################################################
56ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
57DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC)
58DPDK_MACHINE ?= nhm
59DPDK_TUNE ?= core-avx2
60
61##############################################################################
62# ARM64
63##############################################################################
64else ifeq ($(MACHINE),aarch64)
65CROSS :=
66export CROSS
67DPDK_TARGET ?= arm64-armv8a-linuxapp-$(DPDK_CC)
68DPDK_MACHINE ?= armv8a
69DPDK_TUNE ?= generic
70
71CPU_IMP_ARM = 0x41
72CPU_IMP_CAVIUM = 0x43
73
74CPU_PART_ARM_CORTEX_A53 = 0xd03
75CPU_PART_ARM_CORTEX_A57 = 0xd07
76CPU_PART_ARM_CORTEX_A72 = 0xd08
77CPU_PART_ARM_CORTEX_A73 = 0xd09
78
79CPU_PART_CAVIUM_THUNDERX = 0x0a1
80CPU_PART_CAVIUM_THUNDERX_81XX = 0x0a2
81CPU_PART_CAVIUM_THUNDERX_83XX = 0x0a3
82
83MIDR_IMPLEMENTER=$(shell awk '/implementer/ {print $$4;exit}' /proc/cpuinfo)
84MIDR_PARTNUM=$(shell awk '/part/ {print $$4;exit}' /proc/cpuinfo)
85
86ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_ARM))
87##############################################################################
88# Arm Cortex
89##############################################################################
90CPU_PART_ARM_TUNE := $(CPU_PART_ARM_CORTEX_A53)/cortex-a53 \
91 $(CPU_PART_ARM_CORTEX_A57)/cortex-a57 \
92 $(CPU_PART_ARM_CORTEX_A72)/cortex-a72 \
93 $(CPU_PART_ARM_CORTEX_A73)/cortex-a73
94CPU_TUNE = $(notdir $(filter $(MIDR_PARTNUM)/%,$(CPU_PART_ARM_TUNE)))
95ifneq ($(CPU_TUNE),)
96DPDK_TUNE = $(CPU_TUNE)
97else
98$(warning Unknown Arm CPU)
99endif
100
101else ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_CAVIUM))
102##############################################################################
103# Cavium ThunderX
104##############################################################################
105ifneq (,$(findstring $(MIDR_PARTNUM),$(CPU_PART_CAVIUM_THUNDERX) \
106 $(CPU_PART_CAVIUM_THUNDERX_81XX) $(CPU_PART_CAVIUM_THUNDERX_83XX)))
107DPDK_TARGET = arm64-thunderx-linuxapp-$(DPDK_CC)
108DPDK_MACHINE = thunderx
109DPDK_CACHE_LINE_SIZE := 128
110else
111$(warning Unknown Cavium CPU)
112endif
113endif
114
115##############################################################################
116# Unknown platform
117##############################################################################
118else
119$(error Unknown platform)
120endif
121
122# compiler/linker custom arguments
123ifeq ($(DPDK_CC),clang)
124DPDK_CPU_CFLAGS := -fPIE -fPIC
125else
126DPDK_CPU_CFLAGS := -pie -fPIC
127endif
128
129ifeq ($(DPDK_DEBUG),n)
130DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
131else
132DPDK_EXTRA_CFLAGS := -g -O0
133endif
134
135# -Wimplicit-fallthrough was introduced starting from GCC 7,
136# and it requires newer version of ccache.
137# Disable fallthrough warning for old ccache version.
138ifeq ($(DPDK_CC),gcc)
139GCC_VER_V = "7.0.0"
140CCACHE_VER_V = "3.4.1"
141GCC_VER = $(shell gcc --version | grep ^gcc | sed 's/^.* //g')
142CCACHE_VER = $(shell ccache --version | grep ^ccache | sed 's/^.* //g')
143ifeq ($(shell expr "$(GCC_VER)" ">=" "$(GCC_VER_V)"),1)
144ifeq ($(shell expr "$(CCACHE_VER)" "<" "$(CCACHE_VER_V)"),1)
145DPDK_EXTRA_CFLAGS += -Wimplicit-fallthrough=0
146endif
147endif
148endif
149
150DPDK_EXTRA_CFLAGS += -L$(I)/lib -I$(I)/include
151
152# assemble DPDK make arguments
153DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
154 T=$(DPDK_TARGET) \
155 RTE_CONFIG_TEMPLATE=../custom-config \
156 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
157 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
158 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
159 DESTDIR=$(I) \
160 $(DPDK_MAKE_EXTRA_ARGS)
161
162define set
163@if grep -q CONFIG_$1 $@ ; \
164 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
165 else echo CONFIG_$1=$2 >> $@ ; \
166fi
167endef
168
Benoît Gannefe750c22019-03-25 11:41:34 +0100169$(B)/custom-config: $(B)/.dpdk-patch.ok Makefile
Damjan Marion561f2732018-09-21 12:27:45 +0200170 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
171 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
172 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
173 @# modify options
174 $(call set,RTE_MAX_LCORE,256)
175 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
176 $(call set,RTE_CACHE_LINE_SIZE,$(DPDK_CACHE_LINE_SIZE))
177 $(call set,RTE_LIBEAL_USE_HPET,y)
178 $(call set,RTE_BUILD_COMBINE_LIBS,y)
179 $(call set,RTE_PCI_CONFIG,y)
180 $(call set,RTE_PCI_EXTENDED_TAG,"on")
181 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Damjan Marion561f2732018-09-21 12:27:45 +0200182 $(call set,RTE_LIBRTE_PMD_BOND,y)
183 $(call set,RTE_LIBRTE_IP_FRAG,y)
184 $(call set,RTE_LIBRTE_PMD_QAT,y)
Radu Nicolau8b9525c2018-10-01 15:57:31 +0100185 $(call set,RTE_LIBRTE_PMD_QAT_SYM,y)
Damjan Marion561f2732018-09-21 12:27:45 +0200186 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI))
187 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI))
188 $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD))
189 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
190 $(call set,RTE_LIBRTE_PMD_SOFTNIC,n)
Benoît Gannef3262a22019-04-08 13:45:33 +0200191 $(call set,RTE_IBVERBS_LINK_DLOPEN,y)
Damjan Marion561f2732018-09-21 12:27:45 +0200192 $(call set,RTE_LIBRTE_PMD_TAP,$(DPDK_TAP_PMD))
Matthew Smith21302842018-10-29 16:35:30 -0500193 $(call set,RTE_LIBRTE_GSO,$(DPDK_TAP_PMD))
Damjan Marion561f2732018-09-21 12:27:45 +0200194 $(call set,RTE_LIBRTE_PMD_FAILSAFE,$(DPDK_FAILSAFE_PMD))
195 @# not needed
Stephen Hemmingera35fc462018-10-23 16:15:58 -0700196 $(call set,RTE_ETHDEV_RXTX_CALLBACKS,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200197 $(call set,RTE_LIBRTE_CFGFILE,n)
198 $(call set,RTE_LIBRTE_LPM,n)
199 $(call set,RTE_LIBRTE_ACL,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700200 $(call set,RTE_LIBRTE_JOBSTATS,n)
201 $(call set,RTE_LIBRTE_EFD,n)
202 $(call set,RTE_LIBRTE_MEMBER,n)
203 $(call set,RTE_LIBRTE_BITRATE,n)
204 $(call set,RTE_LIBRTE_LATENCY_STATS,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200205 $(call set,RTE_LIBRTE_POWER,n)
206 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
207 $(call set,RTE_LIBRTE_PORT,n)
208 $(call set,RTE_LIBRTE_TABLE,n)
209 $(call set,RTE_LIBRTE_PIPELINE,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700210 $(call set,RTE_LIBRTE_PMD_SOFTNIC,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200211 $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700212 $(call set,RTE_LIBRTE_ACL,n)
213 $(call set,RTE_LIBRTE_GRO,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700214 $(call set,RTE_LIBRTE_KNI,n)
215 $(call set,RTE_LIBRTE_BPF,n)
216 $(call set,RTE_LIBRTE_RAWDEV,n)
217 $(call set,RTE_LIBRTE_PMD_IFPGA_RAWDEV,n)
218 $(call set,RTE_LIBRTE_IFPGA_BUS,n)
219 $(call set,RTE_LIBRTE_BBDEV,n)
220 $(call set,RTE_LIBRTE_BBDEV_NULL,n)
221 $(call set,RTE_TEST_PMD,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200222 $(call set,RTE_KNI_KMOD,n)
223 $(call set,RTE_EAL_IGB_UIO,n)
224 @# currently broken in 18.02
225 $(call set,RTE_LIBRTE_DPAA_BUS,n)
226 $(call set,RTE_LIBRTE_DPAA_MEMPOOL,n)
227 $(call set,RTE_LIBRTE_DPAA_PMD,n)
228 $(call set,RTE_LIBRTE_PMD_DPAA_SEC,n)
229 $(call set,RTE_LIBRTE_PMD_DPAA_EVENTDEV,n)
Benoît Gannefe750c22019-03-25 11:41:34 +0100230 @rm -f .dpdk-config.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200231
Benoît Gannefe750c22019-03-25 11:41:34 +0100232DPDK_DOWNLOADS = $(CURDIR)/downloads/$(DPDK_TARBALL)
233
234$(DPDK_DOWNLOADS):
235 mkdir -p downloads
Damjan Marion561f2732018-09-21 12:27:45 +0200236 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
Benoît Gannefe750c22019-03-25 11:41:34 +0100237 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $@ ; \
238 else curl -o $@ -LO $(DPDK_TAR_URL) ; \
Damjan Marion561f2732018-09-21 12:27:45 +0200239 fi
Benoît Gannefe750c22019-03-25 11:41:34 +0100240 @rm -f $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200241
Benoît Gannefe750c22019-03-25 11:41:34 +0100242$(B)/.dpdk-download.ok: $(DPDK_DOWNLOADS)
Damjan Marion561f2732018-09-21 12:27:45 +0200243 @mkdir -p $(B)
244 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
245 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
246 ( echo "Bad Checksum! Please remove $< and retry" && \
247 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
248 @touch $@
249
Benoît Gannefe750c22019-03-25 11:41:34 +0100250.PHONY: dpdk-download
251dpdk-download: $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200252
Benoît Gannefe750c22019-03-25 11:41:34 +0100253$(B)/.dpdk-extract.ok: $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200254 @echo --- extracting $(DPDK_TARBALL) ---
Benoît Gannefe750c22019-03-25 11:41:34 +0100255 @tar --directory $(B) --extract --file $(DPDK_DOWNLOADS)
Damjan Marion561f2732018-09-21 12:27:45 +0200256 @touch $@
257
Benoît Gannefe750c22019-03-25 11:41:34 +0100258.PHONY: dpdk-extract
259dpdk-extract: $(B)/.dpdk-extract.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200260
Benoît Gannefe750c22019-03-25 11:41:34 +0100261$(B)/.dpdk-patch.ok: $(B)/.dpdk-extract.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200262ifneq ($(wildcard $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch),)
263 @echo --- patching ---
264 @for f in $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch ; do \
265 echo Applying patch: $$(basename $$f) ; \
266 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
267 done
268endif
269 @touch $@
270
Benoît Gannefe750c22019-03-25 11:41:34 +0100271.PHONY: dpdk-patch
272dpdk-patch: $(B)/.dpdk-patch.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200273
Benoît Gannefe750c22019-03-25 11:41:34 +0100274$(B)/.dpdk-config.ok: $(B)/.dpdk-patch.ok $(B)/custom-config
Damjan Marion561f2732018-09-21 12:27:45 +0200275 @make $(DPDK_MAKE_ARGS) config
276 @touch $@
277
Benoît Gannefe750c22019-03-25 11:41:34 +0100278.PHONY: dpdk-config
279dpdk-config: $(B)/.dpdk-config.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200280
Benoît Gannefe750c22019-03-25 11:41:34 +0100281$(B)/.dpdk-build.ok: dpdk-config $(DPDK_BUILD_DEPS)
282 @if [ ! -e $(B)/.dpdk-config.ok ] ; then echo 'Please run "make config" first' && false ; fi
Damjan Marion561f2732018-09-21 12:27:45 +0200283 @make $(DPDK_MAKE_ARGS) install
Damjan Marion561f2732018-09-21 12:27:45 +0200284 @touch $@
285
Benoît Gannefe750c22019-03-25 11:41:34 +0100286.PHONY: dpdk-build
287dpdk-build: $(B)/.dpdk-build.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200288
Benoît Gannefe750c22019-03-25 11:41:34 +0100289.PHONY: dpdk-install
290dpdk-install: $(B)/.dpdk-build.ok