blob: ae9d9c5df956c19736b0aae312722781dc41d671 [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
Matthew Smith84caa172019-02-28 10:33:12 -060020DPDK_MLX_IBVERBS_DLOPEN ?= n
Damjan Marion561f2732018-09-21 12:27:45 +020021DPDK_TAP_PMD ?= n
22DPDK_FAILSAFE_PMD ?= n
23
Damjan Marion1a6ece32019-02-02 16:28:16 +010024DPDK_VERSION ?= 19.02
Damjan Marion561f2732018-09-21 12:27:45 +020025DPDK_BASE_URL ?= http://fast.dpdk.org/rel
26DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
27DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Damjan Marion14033aa2018-11-27 12:18:26 +010028DPDK_18.11_TARBALL_MD5_CKSUM := 04b86f4a77f4f81a7fbd26467dd2ea9f
Damjan Marion1a6ece32019-02-02 16:28:16 +010029DPDK_19.02_TARBALL_MD5_CKSUM := 23944a2cdee061aa4bd72ebe7d836db0
Damjan Marion561f2732018-09-21 12:27:45 +020030MACHINE=$(shell uname -m)
31
32# replace dot with space, and if 3rd word exists we deal with stable dpdk rel
33ifeq ($(word 3,$(subst ., ,$(DPDK_VERSION))),)
34DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
35else
36DPDK_SOURCE := $(B)/dpdk-stable-$(DPDK_VERSION)
37endif
38
39ifeq ($(MACHINE),$(filter $(MACHINE),x86_64))
40 AESNI ?= y
41 DPDK_BUILD_DEPS := ipsec-mb-install
42else
43 AESNI ?= n
44endif
45
46ifneq (,$(findstring clang,$(CC)))
47DPDK_CC=clang
48else ifneq (,$(findstring icc,$(CC)))
49DPDK_CC=icc
50else
51DPDK_CC=gcc
52endif
53
54##############################################################################
55# Intel x86
56##############################################################################
57ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
58DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC)
59DPDK_MACHINE ?= nhm
60DPDK_TUNE ?= core-avx2
61
62##############################################################################
63# ARM64
64##############################################################################
65else ifeq ($(MACHINE),aarch64)
66CROSS :=
67export CROSS
68DPDK_TARGET ?= arm64-armv8a-linuxapp-$(DPDK_CC)
69DPDK_MACHINE ?= armv8a
70DPDK_TUNE ?= generic
71
72CPU_IMP_ARM = 0x41
73CPU_IMP_CAVIUM = 0x43
74
75CPU_PART_ARM_CORTEX_A53 = 0xd03
76CPU_PART_ARM_CORTEX_A57 = 0xd07
77CPU_PART_ARM_CORTEX_A72 = 0xd08
78CPU_PART_ARM_CORTEX_A73 = 0xd09
79
80CPU_PART_CAVIUM_THUNDERX = 0x0a1
81CPU_PART_CAVIUM_THUNDERX_81XX = 0x0a2
82CPU_PART_CAVIUM_THUNDERX_83XX = 0x0a3
83
84MIDR_IMPLEMENTER=$(shell awk '/implementer/ {print $$4;exit}' /proc/cpuinfo)
85MIDR_PARTNUM=$(shell awk '/part/ {print $$4;exit}' /proc/cpuinfo)
86
87ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_ARM))
88##############################################################################
89# Arm Cortex
90##############################################################################
91CPU_PART_ARM_TUNE := $(CPU_PART_ARM_CORTEX_A53)/cortex-a53 \
92 $(CPU_PART_ARM_CORTEX_A57)/cortex-a57 \
93 $(CPU_PART_ARM_CORTEX_A72)/cortex-a72 \
94 $(CPU_PART_ARM_CORTEX_A73)/cortex-a73
95CPU_TUNE = $(notdir $(filter $(MIDR_PARTNUM)/%,$(CPU_PART_ARM_TUNE)))
96ifneq ($(CPU_TUNE),)
97DPDK_TUNE = $(CPU_TUNE)
98else
99$(warning Unknown Arm CPU)
100endif
101
102else ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_CAVIUM))
103##############################################################################
104# Cavium ThunderX
105##############################################################################
106ifneq (,$(findstring $(MIDR_PARTNUM),$(CPU_PART_CAVIUM_THUNDERX) \
107 $(CPU_PART_CAVIUM_THUNDERX_81XX) $(CPU_PART_CAVIUM_THUNDERX_83XX)))
108DPDK_TARGET = arm64-thunderx-linuxapp-$(DPDK_CC)
109DPDK_MACHINE = thunderx
110DPDK_CACHE_LINE_SIZE := 128
111else
112$(warning Unknown Cavium CPU)
113endif
114endif
115
116##############################################################################
117# Unknown platform
118##############################################################################
119else
120$(error Unknown platform)
121endif
122
123# compiler/linker custom arguments
124ifeq ($(DPDK_CC),clang)
125DPDK_CPU_CFLAGS := -fPIE -fPIC
126else
127DPDK_CPU_CFLAGS := -pie -fPIC
128endif
129
130ifeq ($(DPDK_DEBUG),n)
131DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
132else
133DPDK_EXTRA_CFLAGS := -g -O0
134endif
135
136# -Wimplicit-fallthrough was introduced starting from GCC 7,
137# and it requires newer version of ccache.
138# Disable fallthrough warning for old ccache version.
139ifeq ($(DPDK_CC),gcc)
140GCC_VER_V = "7.0.0"
141CCACHE_VER_V = "3.4.1"
142GCC_VER = $(shell gcc --version | grep ^gcc | sed 's/^.* //g')
143CCACHE_VER = $(shell ccache --version | grep ^ccache | sed 's/^.* //g')
144ifeq ($(shell expr "$(GCC_VER)" ">=" "$(GCC_VER_V)"),1)
145ifeq ($(shell expr "$(CCACHE_VER)" "<" "$(CCACHE_VER_V)"),1)
146DPDK_EXTRA_CFLAGS += -Wimplicit-fallthrough=0
147endif
148endif
149endif
150
151DPDK_EXTRA_CFLAGS += -L$(I)/lib -I$(I)/include
152
153# assemble DPDK make arguments
154DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
155 T=$(DPDK_TARGET) \
156 RTE_CONFIG_TEMPLATE=../custom-config \
157 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
158 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
159 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
160 DESTDIR=$(I) \
161 $(DPDK_MAKE_EXTRA_ARGS)
162
163define set
164@if grep -q CONFIG_$1 $@ ; \
165 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
166 else echo CONFIG_$1=$2 >> $@ ; \
167fi
168endef
169
Benoît Gannefe750c22019-03-25 11:41:34 +0100170$(B)/custom-config: $(B)/.dpdk-patch.ok Makefile
Damjan Marion561f2732018-09-21 12:27:45 +0200171 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
172 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
173 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
174 @# modify options
175 $(call set,RTE_MAX_LCORE,256)
176 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
177 $(call set,RTE_CACHE_LINE_SIZE,$(DPDK_CACHE_LINE_SIZE))
178 $(call set,RTE_LIBEAL_USE_HPET,y)
179 $(call set,RTE_BUILD_COMBINE_LIBS,y)
180 $(call set,RTE_PCI_CONFIG,y)
181 $(call set,RTE_PCI_EXTENDED_TAG,"on")
182 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Damjan Marion561f2732018-09-21 12:27:45 +0200183 $(call set,RTE_LIBRTE_PMD_BOND,y)
184 $(call set,RTE_LIBRTE_IP_FRAG,y)
185 $(call set,RTE_LIBRTE_PMD_QAT,y)
Radu Nicolau8b9525c2018-10-01 15:57:31 +0100186 $(call set,RTE_LIBRTE_PMD_QAT_SYM,y)
Damjan Marion561f2732018-09-21 12:27:45 +0200187 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI))
188 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI))
189 $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD))
190 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
191 $(call set,RTE_LIBRTE_PMD_SOFTNIC,n)
Matthew Smith84caa172019-02-28 10:33:12 -0600192 $(call set,RTE_IBVERBS_LINK_DLOPEN,$(DPDK_MLX_IBVERBS_DLOPEN))
Damjan Marion561f2732018-09-21 12:27:45 +0200193 $(call set,RTE_LIBRTE_PMD_TAP,$(DPDK_TAP_PMD))
Matthew Smith21302842018-10-29 16:35:30 -0500194 $(call set,RTE_LIBRTE_GSO,$(DPDK_TAP_PMD))
Damjan Marion561f2732018-09-21 12:27:45 +0200195 $(call set,RTE_LIBRTE_PMD_FAILSAFE,$(DPDK_FAILSAFE_PMD))
196 @# not needed
Stephen Hemmingera35fc462018-10-23 16:15:58 -0700197 $(call set,RTE_ETHDEV_RXTX_CALLBACKS,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200198 $(call set,RTE_LIBRTE_CFGFILE,n)
199 $(call set,RTE_LIBRTE_LPM,n)
200 $(call set,RTE_LIBRTE_ACL,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700201 $(call set,RTE_LIBRTE_JOBSTATS,n)
202 $(call set,RTE_LIBRTE_EFD,n)
203 $(call set,RTE_LIBRTE_MEMBER,n)
204 $(call set,RTE_LIBRTE_BITRATE,n)
205 $(call set,RTE_LIBRTE_LATENCY_STATS,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200206 $(call set,RTE_LIBRTE_POWER,n)
207 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
208 $(call set,RTE_LIBRTE_PORT,n)
209 $(call set,RTE_LIBRTE_TABLE,n)
210 $(call set,RTE_LIBRTE_PIPELINE,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700211 $(call set,RTE_LIBRTE_PMD_SOFTNIC,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200212 $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700213 $(call set,RTE_LIBRTE_ACL,n)
214 $(call set,RTE_LIBRTE_GRO,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700215 $(call set,RTE_LIBRTE_KNI,n)
216 $(call set,RTE_LIBRTE_BPF,n)
217 $(call set,RTE_LIBRTE_RAWDEV,n)
218 $(call set,RTE_LIBRTE_PMD_IFPGA_RAWDEV,n)
219 $(call set,RTE_LIBRTE_IFPGA_BUS,n)
220 $(call set,RTE_LIBRTE_BBDEV,n)
221 $(call set,RTE_LIBRTE_BBDEV_NULL,n)
222 $(call set,RTE_TEST_PMD,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200223 $(call set,RTE_KNI_KMOD,n)
224 $(call set,RTE_EAL_IGB_UIO,n)
225 @# currently broken in 18.02
226 $(call set,RTE_LIBRTE_DPAA_BUS,n)
227 $(call set,RTE_LIBRTE_DPAA_MEMPOOL,n)
228 $(call set,RTE_LIBRTE_DPAA_PMD,n)
229 $(call set,RTE_LIBRTE_PMD_DPAA_SEC,n)
230 $(call set,RTE_LIBRTE_PMD_DPAA_EVENTDEV,n)
Benoît Gannefe750c22019-03-25 11:41:34 +0100231 @rm -f .dpdk-config.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200232
Benoît Gannefe750c22019-03-25 11:41:34 +0100233DPDK_DOWNLOADS = $(CURDIR)/downloads/$(DPDK_TARBALL)
234
235$(DPDK_DOWNLOADS):
236 mkdir -p downloads
Damjan Marion561f2732018-09-21 12:27:45 +0200237 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
Benoît Gannefe750c22019-03-25 11:41:34 +0100238 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $@ ; \
239 else curl -o $@ -LO $(DPDK_TAR_URL) ; \
Damjan Marion561f2732018-09-21 12:27:45 +0200240 fi
Benoît Gannefe750c22019-03-25 11:41:34 +0100241 @rm -f $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200242
Benoît Gannefe750c22019-03-25 11:41:34 +0100243$(B)/.dpdk-download.ok: $(DPDK_DOWNLOADS)
Damjan Marion561f2732018-09-21 12:27:45 +0200244 @mkdir -p $(B)
245 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
246 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
247 ( echo "Bad Checksum! Please remove $< and retry" && \
248 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
249 @touch $@
250
Benoît Gannefe750c22019-03-25 11:41:34 +0100251.PHONY: dpdk-download
252dpdk-download: $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200253
Benoît Gannefe750c22019-03-25 11:41:34 +0100254$(B)/.dpdk-extract.ok: $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200255 @echo --- extracting $(DPDK_TARBALL) ---
Benoît Gannefe750c22019-03-25 11:41:34 +0100256 @tar --directory $(B) --extract --file $(DPDK_DOWNLOADS)
Damjan Marion561f2732018-09-21 12:27:45 +0200257 @touch $@
258
Benoît Gannefe750c22019-03-25 11:41:34 +0100259.PHONY: dpdk-extract
260dpdk-extract: $(B)/.dpdk-extract.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200261
Benoît Gannefe750c22019-03-25 11:41:34 +0100262$(B)/.dpdk-patch.ok: $(B)/.dpdk-extract.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200263ifneq ($(wildcard $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch),)
264 @echo --- patching ---
265 @for f in $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch ; do \
266 echo Applying patch: $$(basename $$f) ; \
267 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
268 done
269endif
270 @touch $@
271
Benoît Gannefe750c22019-03-25 11:41:34 +0100272.PHONY: dpdk-patch
273dpdk-patch: $(B)/.dpdk-patch.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200274
Benoît Gannefe750c22019-03-25 11:41:34 +0100275$(B)/.dpdk-config.ok: $(B)/.dpdk-patch.ok $(B)/custom-config
Damjan Marion561f2732018-09-21 12:27:45 +0200276 @make $(DPDK_MAKE_ARGS) config
277 @touch $@
278
Benoît Gannefe750c22019-03-25 11:41:34 +0100279.PHONY: dpdk-config
280dpdk-config: $(B)/.dpdk-config.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200281
Benoît Gannefe750c22019-03-25 11:41:34 +0100282$(B)/.dpdk-build.ok: dpdk-config $(DPDK_BUILD_DEPS)
283 @if [ ! -e $(B)/.dpdk-config.ok ] ; then echo 'Please run "make config" first' && false ; fi
Damjan Marion561f2732018-09-21 12:27:45 +0200284 @make $(DPDK_MAKE_ARGS) install
Damjan Marion561f2732018-09-21 12:27:45 +0200285 @touch $@
286
Benoît Gannefe750c22019-03-25 11:41:34 +0100287.PHONY: dpdk-build
288dpdk-build: $(B)/.dpdk-build.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200289
Benoît Gannefe750c22019-03-25 11:41:34 +0100290.PHONY: dpdk-install
291dpdk-install: $(B)/.dpdk-build.ok