blob: 2ade07b5431040789b6d376857f099e964a88384 [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
Lijian.Zhang49c1bc82019-02-27 18:17:34 +080018DPDK_AARCH64_GENERIC ?= y
Damjan Marion561f2732018-09-21 12:27:45 +020019DPDK_MLX4_PMD ?= n
20DPDK_MLX5_PMD ?= n
21DPDK_TAP_PMD ?= n
22DPDK_FAILSAFE_PMD ?= n
23
Damjan Marion94f32952020-05-27 00:37:49 +020024DPDK_VERSION ?= 20.05
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 Marion76be8872020-02-26 12:49:49 +010029DPDK_20.02_TARBALL_MD5_CKSUM := e20171462d6b2252dfbae1de8c45ba10
Damjan Marion94f32952020-05-27 00:37:49 +020030DPDK_20.05_TARBALL_MD5_CKSUM := 7c6f3e7f7de2422775c4cba116012c4d
Damjan Marion561f2732018-09-21 12:27:45 +020031MACHINE=$(shell uname -m)
32
33# replace dot with space, and if 3rd word exists we deal with stable dpdk rel
34ifeq ($(word 3,$(subst ., ,$(DPDK_VERSION))),)
35DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
36else
37DPDK_SOURCE := $(B)/dpdk-stable-$(DPDK_VERSION)
38endif
39
40ifeq ($(MACHINE),$(filter $(MACHINE),x86_64))
41 AESNI ?= y
42 DPDK_BUILD_DEPS := ipsec-mb-install
43else
44 AESNI ?= n
45endif
46
47ifneq (,$(findstring clang,$(CC)))
48DPDK_CC=clang
49else ifneq (,$(findstring icc,$(CC)))
50DPDK_CC=icc
51else
52DPDK_CC=gcc
53endif
54
55##############################################################################
56# Intel x86
57##############################################################################
58ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
59DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC)
60DPDK_MACHINE ?= nhm
61DPDK_TUNE ?= core-avx2
62
63##############################################################################
64# ARM64
65##############################################################################
66else ifeq ($(MACHINE),aarch64)
67CROSS :=
68export CROSS
69DPDK_TARGET ?= arm64-armv8a-linuxapp-$(DPDK_CC)
70DPDK_MACHINE ?= armv8a
71DPDK_TUNE ?= generic
Lijian.Zhang49c1bc82019-02-27 18:17:34 +080072ifeq (y, $(DPDK_AARCH64_GENERIC))
73DPDK_CACHE_LINE_SIZE := 128
74# assign aarch64 variant specific options
75else
Damjan Marion561f2732018-09-21 12:27:45 +020076CPU_IMP_ARM = 0x41
77CPU_IMP_CAVIUM = 0x43
78
79CPU_PART_ARM_CORTEX_A53 = 0xd03
80CPU_PART_ARM_CORTEX_A57 = 0xd07
81CPU_PART_ARM_CORTEX_A72 = 0xd08
82CPU_PART_ARM_CORTEX_A73 = 0xd09
83
84CPU_PART_CAVIUM_THUNDERX = 0x0a1
85CPU_PART_CAVIUM_THUNDERX_81XX = 0x0a2
86CPU_PART_CAVIUM_THUNDERX_83XX = 0x0a3
87
88MIDR_IMPLEMENTER=$(shell awk '/implementer/ {print $$4;exit}' /proc/cpuinfo)
89MIDR_PARTNUM=$(shell awk '/part/ {print $$4;exit}' /proc/cpuinfo)
90
91ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_ARM))
92##############################################################################
93# Arm Cortex
94##############################################################################
95CPU_PART_ARM_TUNE := $(CPU_PART_ARM_CORTEX_A53)/cortex-a53 \
96 $(CPU_PART_ARM_CORTEX_A57)/cortex-a57 \
97 $(CPU_PART_ARM_CORTEX_A72)/cortex-a72 \
98 $(CPU_PART_ARM_CORTEX_A73)/cortex-a73
99CPU_TUNE = $(notdir $(filter $(MIDR_PARTNUM)/%,$(CPU_PART_ARM_TUNE)))
100ifneq ($(CPU_TUNE),)
101DPDK_TUNE = $(CPU_TUNE)
102else
103$(warning Unknown Arm CPU)
104endif
105
106else ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_CAVIUM))
107##############################################################################
108# Cavium ThunderX
109##############################################################################
110ifneq (,$(findstring $(MIDR_PARTNUM),$(CPU_PART_CAVIUM_THUNDERX) \
111 $(CPU_PART_CAVIUM_THUNDERX_81XX) $(CPU_PART_CAVIUM_THUNDERX_83XX)))
112DPDK_TARGET = arm64-thunderx-linuxapp-$(DPDK_CC)
113DPDK_MACHINE = thunderx
114DPDK_CACHE_LINE_SIZE := 128
115else
116$(warning Unknown Cavium CPU)
117endif
118endif
119
Lijian.Zhang49c1bc82019-02-27 18:17:34 +0800120# finish of assigning aarch64 variant specific options
121endif
122
Damjan Marion561f2732018-09-21 12:27:45 +0200123##############################################################################
124# Unknown platform
125##############################################################################
126else
127$(error Unknown platform)
128endif
129
130# compiler/linker custom arguments
131ifeq ($(DPDK_CC),clang)
132DPDK_CPU_CFLAGS := -fPIE -fPIC
133else
134DPDK_CPU_CFLAGS := -pie -fPIC
135endif
136
137ifeq ($(DPDK_DEBUG),n)
138DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
139else
140DPDK_EXTRA_CFLAGS := -g -O0
141endif
142
143# -Wimplicit-fallthrough was introduced starting from GCC 7,
144# and it requires newer version of ccache.
145# Disable fallthrough warning for old ccache version.
146ifeq ($(DPDK_CC),gcc)
147GCC_VER_V = "7.0.0"
148CCACHE_VER_V = "3.4.1"
149GCC_VER = $(shell gcc --version | grep ^gcc | sed 's/^.* //g')
150CCACHE_VER = $(shell ccache --version | grep ^ccache | sed 's/^.* //g')
151ifeq ($(shell expr "$(GCC_VER)" ">=" "$(GCC_VER_V)"),1)
152ifeq ($(shell expr "$(CCACHE_VER)" "<" "$(CCACHE_VER_V)"),1)
153DPDK_EXTRA_CFLAGS += -Wimplicit-fallthrough=0
154endif
155endif
156endif
157
Lijian.Zhang88d6ce22020-04-30 14:52:15 +0800158DPDK_EXTRA_CFLAGS += -I$(I)/include
159DPDK_EXTRA_LDFLAGS += -L$(I)/lib
Damjan Marion561f2732018-09-21 12:27:45 +0200160
161# assemble DPDK make arguments
162DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
163 T=$(DPDK_TARGET) \
164 RTE_CONFIG_TEMPLATE=../custom-config \
165 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
166 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
167 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
168 DESTDIR=$(I) \
169 $(DPDK_MAKE_EXTRA_ARGS)
170
171define set
172@if grep -q CONFIG_$1 $@ ; \
173 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
174 else echo CONFIG_$1=$2 >> $@ ; \
175fi
176endef
177
Benoît Gannefe750c22019-03-25 11:41:34 +0100178$(B)/custom-config: $(B)/.dpdk-patch.ok Makefile
Damjan Marion561f2732018-09-21 12:27:45 +0200179 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
180 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
181 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
182 @# modify options
183 $(call set,RTE_MAX_LCORE,256)
184 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
185 $(call set,RTE_CACHE_LINE_SIZE,$(DPDK_CACHE_LINE_SIZE))
Damjan Marion561f2732018-09-21 12:27:45 +0200186 $(call set,RTE_BUILD_COMBINE_LIBS,y)
187 $(call set,RTE_PCI_CONFIG,y)
188 $(call set,RTE_PCI_EXTENDED_TAG,"on")
189 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Damjan Marion048acfb2019-05-29 10:00:46 +0200190 $(call set,RTE_LIBRTE_PMD_BOND,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200191 $(call set,RTE_LIBRTE_IP_FRAG,y)
192 $(call set,RTE_LIBRTE_PMD_QAT,y)
Radu Nicolau8b9525c2018-10-01 15:57:31 +0100193 $(call set,RTE_LIBRTE_PMD_QAT_SYM,y)
Damjan Marion561f2732018-09-21 12:27:45 +0200194 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI))
195 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI))
196 $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD))
197 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
Andy Gospodarekc3731ac2019-11-12 17:55:01 -0500198 $(call set,RTE_LIBRTE_BNXT_PMD,y)
Damjan Marion561f2732018-09-21 12:27:45 +0200199 $(call set,RTE_LIBRTE_PMD_SOFTNIC,n)
Benoît Gannef3262a22019-04-08 13:45:33 +0200200 $(call set,RTE_IBVERBS_LINK_DLOPEN,y)
Damjan Marion561f2732018-09-21 12:27:45 +0200201 $(call set,RTE_LIBRTE_PMD_TAP,$(DPDK_TAP_PMD))
Matthew Smith21302842018-10-29 16:35:30 -0500202 $(call set,RTE_LIBRTE_GSO,$(DPDK_TAP_PMD))
Damjan Marion561f2732018-09-21 12:27:45 +0200203 $(call set,RTE_LIBRTE_PMD_FAILSAFE,$(DPDK_FAILSAFE_PMD))
204 @# not needed
Stephen Hemmingera35fc462018-10-23 16:15:58 -0700205 $(call set,RTE_ETHDEV_RXTX_CALLBACKS,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200206 $(call set,RTE_LIBRTE_CFGFILE,n)
207 $(call set,RTE_LIBRTE_LPM,n)
208 $(call set,RTE_LIBRTE_ACL,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700209 $(call set,RTE_LIBRTE_JOBSTATS,n)
210 $(call set,RTE_LIBRTE_EFD,n)
211 $(call set,RTE_LIBRTE_MEMBER,n)
212 $(call set,RTE_LIBRTE_BITRATE,n)
213 $(call set,RTE_LIBRTE_LATENCY_STATS,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200214 $(call set,RTE_LIBRTE_POWER,n)
215 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
216 $(call set,RTE_LIBRTE_PORT,n)
217 $(call set,RTE_LIBRTE_TABLE,n)
218 $(call set,RTE_LIBRTE_PIPELINE,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700219 $(call set,RTE_LIBRTE_PMD_SOFTNIC,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200220 $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700221 $(call set,RTE_LIBRTE_ACL,n)
222 $(call set,RTE_LIBRTE_GRO,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700223 $(call set,RTE_LIBRTE_KNI,n)
224 $(call set,RTE_LIBRTE_BPF,n)
225 $(call set,RTE_LIBRTE_RAWDEV,n)
226 $(call set,RTE_LIBRTE_PMD_IFPGA_RAWDEV,n)
Damjan Mariona9116242019-05-29 09:48:44 +0200227 $(call set,RTE_LIBRTE_IPN3KE_PMD,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700228 $(call set,RTE_LIBRTE_IFPGA_BUS,n)
229 $(call set,RTE_LIBRTE_BBDEV,n)
230 $(call set,RTE_LIBRTE_BBDEV_NULL,n)
Damjan Marion94f32952020-05-27 00:37:49 +0200231 $(call set,RTE_LIBRTE_GRAPH,n)
232 $(call set,RTE_LIBRTE_NODE,n)
233 $(call set,RTE_LIBRTE_FIB,n)
234 $(call set,RTE_LIBRTE_RIB,n)
Stephen Hemminger939ce112018-10-19 12:29:57 -0700235 $(call set,RTE_TEST_PMD,n)
Damjan Marion561f2732018-09-21 12:27:45 +0200236 $(call set,RTE_KNI_KMOD,n)
237 $(call set,RTE_EAL_IGB_UIO,n)
238 @# currently broken in 18.02
239 $(call set,RTE_LIBRTE_DPAA_BUS,n)
240 $(call set,RTE_LIBRTE_DPAA_MEMPOOL,n)
241 $(call set,RTE_LIBRTE_DPAA_PMD,n)
242 $(call set,RTE_LIBRTE_PMD_DPAA_SEC,n)
243 $(call set,RTE_LIBRTE_PMD_DPAA_EVENTDEV,n)
Benoît Gannefe750c22019-03-25 11:41:34 +0100244 @rm -f .dpdk-config.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200245
Benoît Gannefe750c22019-03-25 11:41:34 +0100246DPDK_DOWNLOADS = $(CURDIR)/downloads/$(DPDK_TARBALL)
247
248$(DPDK_DOWNLOADS):
249 mkdir -p downloads
Damjan Marion561f2732018-09-21 12:27:45 +0200250 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
Benoît Gannefe750c22019-03-25 11:41:34 +0100251 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $@ ; \
252 else curl -o $@ -LO $(DPDK_TAR_URL) ; \
Damjan Marion561f2732018-09-21 12:27:45 +0200253 fi
Benoît Gannefe750c22019-03-25 11:41:34 +0100254 @rm -f $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200255
Benoît Gannefe750c22019-03-25 11:41:34 +0100256$(B)/.dpdk-download.ok: $(DPDK_DOWNLOADS)
Damjan Marion561f2732018-09-21 12:27:45 +0200257 @mkdir -p $(B)
258 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
259 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
260 ( echo "Bad Checksum! Please remove $< and retry" && \
261 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
262 @touch $@
263
Benoît Gannefe750c22019-03-25 11:41:34 +0100264.PHONY: dpdk-download
265dpdk-download: $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200266
Benoît Gannefe750c22019-03-25 11:41:34 +0100267$(B)/.dpdk-extract.ok: $(B)/.dpdk-download.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200268 @echo --- extracting $(DPDK_TARBALL) ---
Benoît Gannefe750c22019-03-25 11:41:34 +0100269 @tar --directory $(B) --extract --file $(DPDK_DOWNLOADS)
Damjan Marion561f2732018-09-21 12:27:45 +0200270 @touch $@
271
Benoît Gannefe750c22019-03-25 11:41:34 +0100272.PHONY: dpdk-extract
273dpdk-extract: $(B)/.dpdk-extract.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200274
Benoît Gannefe750c22019-03-25 11:41:34 +0100275$(B)/.dpdk-patch.ok: $(B)/.dpdk-extract.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200276ifneq ($(wildcard $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch),)
277 @echo --- patching ---
278 @for f in $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch ; do \
279 echo Applying patch: $$(basename $$f) ; \
280 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
281 done
282endif
283 @touch $@
284
Benoît Gannefe750c22019-03-25 11:41:34 +0100285.PHONY: dpdk-patch
286dpdk-patch: $(B)/.dpdk-patch.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200287
Benoît Gannefe750c22019-03-25 11:41:34 +0100288$(B)/.dpdk-config.ok: $(B)/.dpdk-patch.ok $(B)/custom-config
Damjan Marion561f2732018-09-21 12:27:45 +0200289 @make $(DPDK_MAKE_ARGS) config
290 @touch $@
291
Benoît Gannefe750c22019-03-25 11:41:34 +0100292.PHONY: dpdk-config
293dpdk-config: $(B)/.dpdk-config.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200294
Benoît Gannefe750c22019-03-25 11:41:34 +0100295$(B)/.dpdk-build.ok: dpdk-config $(DPDK_BUILD_DEPS)
296 @if [ ! -e $(B)/.dpdk-config.ok ] ; then echo 'Please run "make config" first' && false ; fi
Burt Silverman839a7bc2019-09-30 09:50:42 -0400297 @rm -f $(B)/.*.install.ok #deals with build-root/Makefile line 709
Damjan Marion561f2732018-09-21 12:27:45 +0200298 @make $(DPDK_MAKE_ARGS) install
Damjan Marion561f2732018-09-21 12:27:45 +0200299 @touch $@
300
Benoît Gannefe750c22019-03-25 11:41:34 +0100301.PHONY: dpdk-build
302dpdk-build: $(B)/.dpdk-build.ok
Damjan Marion561f2732018-09-21 12:27:45 +0200303
Benoît Gannefe750c22019-03-25 11:41:34 +0100304.PHONY: dpdk-install
305dpdk-install: $(B)/.dpdk-build.ok