Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 1 | # 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 | |
| 14 | DPDK_PKTMBUF_HEADROOM ?= 128 |
| 15 | DPDK_CACHE_LINE_SIZE ?= 64 |
| 16 | DPDK_DOWNLOAD_DIR ?= $(DL_CACHE_DIR) |
| 17 | DPDK_DEBUG ?= n |
| 18 | DPDK_MLX4_PMD ?= n |
| 19 | DPDK_MLX5_PMD ?= n |
Sirshak Das | c263e48 | 2018-09-22 14:57:26 -0500 | [diff] [blame] | 20 | DPDK_MLX5_PMD_DLOPEN_DEPS ?= n |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 21 | DPDK_TAP_PMD ?= n |
| 22 | DPDK_FAILSAFE_PMD ?= n |
| 23 | |
| 24 | DPDK_VERSION ?= 18.08 |
| 25 | DPDK_BASE_URL ?= http://fast.dpdk.org/rel |
| 26 | DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz |
| 27 | DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL) |
| 28 | DPDK_18.05_TARBALL_MD5_CKSUM := 9fc86367cd9407ff6a8dfea56c4eddc4 |
| 29 | DPDK_18.08_TARBALL_MD5_CKSUM := da5e7fb25ab063c47e53929fb8c58be5 |
| 30 | MACHINE=$(shell uname -m) |
| 31 | |
| 32 | # replace dot with space, and if 3rd word exists we deal with stable dpdk rel |
| 33 | ifeq ($(word 3,$(subst ., ,$(DPDK_VERSION))),) |
| 34 | DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION) |
| 35 | else |
| 36 | DPDK_SOURCE := $(B)/dpdk-stable-$(DPDK_VERSION) |
| 37 | endif |
| 38 | |
| 39 | ifeq ($(MACHINE),$(filter $(MACHINE),x86_64)) |
| 40 | AESNI ?= y |
| 41 | DPDK_BUILD_DEPS := ipsec-mb-install |
| 42 | else |
| 43 | AESNI ?= n |
| 44 | endif |
| 45 | |
| 46 | ifneq (,$(findstring clang,$(CC))) |
| 47 | DPDK_CC=clang |
| 48 | else ifneq (,$(findstring icc,$(CC))) |
| 49 | DPDK_CC=icc |
| 50 | else |
| 51 | DPDK_CC=gcc |
| 52 | endif |
| 53 | |
| 54 | ############################################################################## |
| 55 | # Intel x86 |
| 56 | ############################################################################## |
| 57 | ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686)) |
| 58 | DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC) |
| 59 | DPDK_MACHINE ?= nhm |
| 60 | DPDK_TUNE ?= core-avx2 |
| 61 | |
| 62 | ############################################################################## |
| 63 | # ARM64 |
| 64 | ############################################################################## |
| 65 | else ifeq ($(MACHINE),aarch64) |
| 66 | CROSS := |
| 67 | export CROSS |
| 68 | DPDK_TARGET ?= arm64-armv8a-linuxapp-$(DPDK_CC) |
| 69 | DPDK_MACHINE ?= armv8a |
| 70 | DPDK_TUNE ?= generic |
| 71 | |
| 72 | CPU_IMP_ARM = 0x41 |
| 73 | CPU_IMP_CAVIUM = 0x43 |
| 74 | |
| 75 | CPU_PART_ARM_CORTEX_A53 = 0xd03 |
| 76 | CPU_PART_ARM_CORTEX_A57 = 0xd07 |
| 77 | CPU_PART_ARM_CORTEX_A72 = 0xd08 |
| 78 | CPU_PART_ARM_CORTEX_A73 = 0xd09 |
| 79 | |
| 80 | CPU_PART_CAVIUM_THUNDERX = 0x0a1 |
| 81 | CPU_PART_CAVIUM_THUNDERX_81XX = 0x0a2 |
| 82 | CPU_PART_CAVIUM_THUNDERX_83XX = 0x0a3 |
| 83 | |
| 84 | MIDR_IMPLEMENTER=$(shell awk '/implementer/ {print $$4;exit}' /proc/cpuinfo) |
| 85 | MIDR_PARTNUM=$(shell awk '/part/ {print $$4;exit}' /proc/cpuinfo) |
| 86 | |
| 87 | ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_ARM)) |
| 88 | ############################################################################## |
| 89 | # Arm Cortex |
| 90 | ############################################################################## |
| 91 | CPU_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 |
| 95 | CPU_TUNE = $(notdir $(filter $(MIDR_PARTNUM)/%,$(CPU_PART_ARM_TUNE))) |
| 96 | ifneq ($(CPU_TUNE),) |
| 97 | DPDK_TUNE = $(CPU_TUNE) |
| 98 | else |
| 99 | $(warning Unknown Arm CPU) |
| 100 | endif |
| 101 | |
| 102 | else ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_CAVIUM)) |
| 103 | ############################################################################## |
| 104 | # Cavium ThunderX |
| 105 | ############################################################################## |
| 106 | ifneq (,$(findstring $(MIDR_PARTNUM),$(CPU_PART_CAVIUM_THUNDERX) \ |
| 107 | $(CPU_PART_CAVIUM_THUNDERX_81XX) $(CPU_PART_CAVIUM_THUNDERX_83XX))) |
| 108 | DPDK_TARGET = arm64-thunderx-linuxapp-$(DPDK_CC) |
| 109 | DPDK_MACHINE = thunderx |
| 110 | DPDK_CACHE_LINE_SIZE := 128 |
| 111 | else |
| 112 | $(warning Unknown Cavium CPU) |
| 113 | endif |
| 114 | endif |
| 115 | |
| 116 | ############################################################################## |
| 117 | # Unknown platform |
| 118 | ############################################################################## |
| 119 | else |
| 120 | $(error Unknown platform) |
| 121 | endif |
| 122 | |
| 123 | # compiler/linker custom arguments |
| 124 | ifeq ($(DPDK_CC),clang) |
| 125 | DPDK_CPU_CFLAGS := -fPIE -fPIC |
| 126 | else |
| 127 | DPDK_CPU_CFLAGS := -pie -fPIC |
| 128 | endif |
| 129 | |
| 130 | ifeq ($(DPDK_DEBUG),n) |
| 131 | DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE) |
| 132 | else |
| 133 | DPDK_EXTRA_CFLAGS := -g -O0 |
| 134 | endif |
| 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. |
| 139 | ifeq ($(DPDK_CC),gcc) |
| 140 | GCC_VER_V = "7.0.0" |
| 141 | CCACHE_VER_V = "3.4.1" |
| 142 | GCC_VER = $(shell gcc --version | grep ^gcc | sed 's/^.* //g') |
| 143 | CCACHE_VER = $(shell ccache --version | grep ^ccache | sed 's/^.* //g') |
| 144 | ifeq ($(shell expr "$(GCC_VER)" ">=" "$(GCC_VER_V)"),1) |
| 145 | ifeq ($(shell expr "$(CCACHE_VER)" "<" "$(CCACHE_VER_V)"),1) |
| 146 | DPDK_EXTRA_CFLAGS += -Wimplicit-fallthrough=0 |
| 147 | endif |
| 148 | endif |
| 149 | endif |
| 150 | |
| 151 | DPDK_EXTRA_CFLAGS += -L$(I)/lib -I$(I)/include |
| 152 | |
| 153 | # assemble DPDK make arguments |
| 154 | DPDK_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 | |
| 163 | define set |
| 164 | @if grep -q CONFIG_$1 $@ ; \ |
| 165 | then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \ |
| 166 | else echo CONFIG_$1=$2 >> $@ ; \ |
| 167 | fi |
| 168 | endef |
| 169 | |
| 170 | all: build |
| 171 | |
| 172 | $(B)/custom-config: $(B)/.patch.ok Makefile |
| 173 | @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) --- |
| 174 | @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@ |
| 175 | $(call set,RTE_MACHINE,$(DPDK_MACHINE)) |
| 176 | @# modify options |
| 177 | $(call set,RTE_MAX_LCORE,256) |
| 178 | $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM)) |
| 179 | $(call set,RTE_CACHE_LINE_SIZE,$(DPDK_CACHE_LINE_SIZE)) |
| 180 | $(call set,RTE_LIBEAL_USE_HPET,y) |
| 181 | $(call set,RTE_BUILD_COMBINE_LIBS,y) |
| 182 | $(call set,RTE_PCI_CONFIG,y) |
| 183 | $(call set,RTE_PCI_EXTENDED_TAG,"on") |
| 184 | $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096) |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 185 | $(call set,RTE_LIBRTE_PMD_BOND,y) |
| 186 | $(call set,RTE_LIBRTE_IP_FRAG,y) |
| 187 | $(call set,RTE_LIBRTE_PMD_QAT,y) |
Radu Nicolau | 8b9525c | 2018-10-01 15:57:31 +0100 | [diff] [blame] | 188 | $(call set,RTE_LIBRTE_PMD_QAT_SYM,y) |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 189 | $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI)) |
| 190 | $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI)) |
| 191 | $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD)) |
| 192 | $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD)) |
| 193 | $(call set,RTE_LIBRTE_PMD_SOFTNIC,n) |
| 194 | $(call set,RTE_LIBRTE_MLX4_DLOPEN_DEPS,$(DPDK_MLX4_PMD)) |
Sirshak Das | c263e48 | 2018-09-22 14:57:26 -0500 | [diff] [blame] | 195 | $(call set,RTE_LIBRTE_MLX5_DLOPEN_DEPS,$(DPDK_MLX5_PMD_DLOPEN_DEPS)) |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 196 | $(call set,RTE_LIBRTE_PMD_TAP,$(DPDK_TAP_PMD)) |
| 197 | $(call set,RTE_LIBRTE_PMD_FAILSAFE,$(DPDK_FAILSAFE_PMD)) |
| 198 | @# not needed |
| 199 | $(call set,RTE_LIBRTE_CFGFILE,n) |
| 200 | $(call set,RTE_LIBRTE_LPM,n) |
| 201 | $(call set,RTE_LIBRTE_ACL,n) |
| 202 | $(call set,RTE_LIBRTE_POWER,n) |
| 203 | $(call set,RTE_LIBRTE_DISTRIBUTOR,n) |
| 204 | $(call set,RTE_LIBRTE_PORT,n) |
| 205 | $(call set,RTE_LIBRTE_TABLE,n) |
| 206 | $(call set,RTE_LIBRTE_PIPELINE,n) |
| 207 | $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n) |
| 208 | $(call set,RTE_KNI_KMOD,n) |
| 209 | $(call set,RTE_EAL_IGB_UIO,n) |
| 210 | @# currently broken in 18.02 |
| 211 | $(call set,RTE_LIBRTE_DPAA_BUS,n) |
| 212 | $(call set,RTE_LIBRTE_DPAA_MEMPOOL,n) |
| 213 | $(call set,RTE_LIBRTE_DPAA_PMD,n) |
| 214 | $(call set,RTE_LIBRTE_PMD_DPAA_SEC,n) |
| 215 | $(call set,RTE_LIBRTE_PMD_DPAA_EVENTDEV,n) |
| 216 | @rm -f .config.ok |
| 217 | |
| 218 | $(CURDIR)/$(DPDK_TARBALL): |
| 219 | @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \ |
| 220 | then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \ |
| 221 | else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \ |
| 222 | fi |
| 223 | @rm -f $(B)/.download.ok |
| 224 | |
| 225 | DPDK_DOWNLOADS = $(CURDIR)/$(DPDK_TARBALL) |
| 226 | |
| 227 | $(B)/.download.ok: $(DPDK_DOWNLOADS) |
| 228 | @mkdir -p $(B) |
| 229 | @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum |
| 230 | @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \ |
| 231 | ( echo "Bad Checksum! Please remove $< and retry" && \ |
| 232 | rm $(B)/$(DPDK_TARBALL).md5sum && false )) |
| 233 | @touch $@ |
| 234 | |
| 235 | .PHONY: download |
| 236 | download: $(B)/.download.ok |
| 237 | |
| 238 | $(B)/.extract.ok: $(B)/.download.ok |
| 239 | @echo --- extracting $(DPDK_TARBALL) --- |
| 240 | @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL) |
| 241 | @touch $@ |
| 242 | |
| 243 | .PHONY: extract |
| 244 | extract: $(B)/.extract.ok |
| 245 | |
| 246 | $(B)/.patch.ok: $(B)/.extract.ok |
| 247 | ifneq ($(wildcard $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch),) |
| 248 | @echo --- patching --- |
| 249 | @for f in $(CURDIR)/patches/dpdk_$(DPDK_VERSION)/*.patch ; do \ |
| 250 | echo Applying patch: $$(basename $$f) ; \ |
| 251 | patch -p1 -d $(DPDK_SOURCE) < $$f ; \ |
| 252 | done |
| 253 | endif |
| 254 | @touch $@ |
| 255 | |
| 256 | .PHONY: patch |
| 257 | patch: $(B)/.patch.ok |
| 258 | |
| 259 | $(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config |
| 260 | @make $(DPDK_MAKE_ARGS) config |
| 261 | @touch $@ |
| 262 | |
| 263 | .PHONY: config |
| 264 | config: $(B)/.config.ok |
| 265 | |
| 266 | .PHONY: build-dpdk |
| 267 | build-dpdk: $(DPDK_BUILD_DEPS) |
| 268 | @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi |
| 269 | @make $(DPDK_MAKE_ARGS) install |
| 270 | |
| 271 | $(B)/.build.ok: build-dpdk |
| 272 | @touch $@ |
| 273 | |
| 274 | .PHONY: build |
| 275 | build: $(B)/.build.ok |
| 276 | |
| 277 | .PHONY: install |
| 278 | install: $(B)/.build.ok |