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