1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright (C) 2016 Intel Corporation. 3# All rights reserved. 4# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5# 6 7# This makefile snippet must define the following flags: 8# ENV_CFLAGS 9# ENV_CXXFLAGS 10# ENV_LIBS 11# ENV_LINKER_ARGS 12# ENV_DEPLIBS 13 14include $(SPDK_ROOT_DIR)/mk/spdk.lib_deps.mk 15 16DPDK_DIR = $(CONFIG_DPDK_DIR) 17 18export DPDK_ABS_DIR = $(abspath $(DPDK_DIR)) 19 20ifneq ($(CONFIG_DPDK_LIB_DIR),) 21DPDK_LIB_DIR = $(CONFIG_DPDK_LIB_DIR) 22else 23DPDK_LIB_DIR = $(DPDK_ABS_DIR)/lib 24endif 25 26ifneq ($(CONFIG_DPDK_INC_DIR),) 27DPDK_INC_DIR = $(CONFIG_DPDK_INC_DIR) 28else 29ifneq (, $(wildcard $(DPDK_ABS_DIR)/include/rte_config.h)) 30DPDK_INC_DIR := $(DPDK_ABS_DIR)/include 31else 32DPDK_INC_DIR := $(DPDK_ABS_DIR)/include/dpdk 33endif 34endif 35 36DPDK_INC := -I$(DPDK_INC_DIR) 37 38DPDK_LIB_LIST = rte_eal rte_mempool rte_ring rte_mbuf rte_bus_pci rte_pci rte_mempool_ring 39DPDK_LIB_LIST += rte_telemetry rte_kvargs rte_rcu 40 41DPDK_POWER=n 42 43ifeq ($(OS),Linux) 44# Despite rte_power was added DPDK 1.6, 45# some DPDK packages do not include it. See #2534. 46ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_power.*)) 47DPDK_POWER=y 48# Since DPDK 21.02 rte_power depends on rte_ethdev that 49# in turn depends on rte_net. 50DPDK_LIB_LIST += rte_power rte_ethdev rte_net 51endif 52endif 53 54# There are some complex dependencies when using crypto, compress or both so 55# here we add the feature specific ones and set a flag to add the common 56# ones after that. 57DPDK_FRAMEWORK=n 58 59ifeq ($(findstring y,$(CONFIG_CRYPTO_MLX5)$(CONFIG_VBDEV_COMPRESS_MLX5)),y) 60DPDK_LIB_LIST += rte_common_mlx5 61# Introduced in DPDK 21.08 62ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_bus_auxiliary.*)) 63DPDK_LIB_LIST += rte_bus_auxiliary 64endif 65endif 66 67ifeq ($(CONFIG_CRYPTO),y) 68DPDK_FRAMEWORK=y 69ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_ipsec_mb.*)) 70# PMD name as of DPDK 21.11 71DPDK_LIB_LIST += rte_crypto_ipsec_mb 72else 73ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_aesni_mb.*)) 74# PMD name for DPDK 21.08 and earlier 75DPDK_LIB_LIST += rte_crypto_aesni_mb 76endif 77endif 78 79ifeq ($(CONFIG_CRYPTO_MLX5),y) 80ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_mlx5.*)) 81DPDK_LIB_LIST += rte_crypto_mlx5 82endif 83endif 84 85ifeq ($(CONFIG_DPDK_UADK),y) 86ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_uadk.*)) 87DPDK_LIB_LIST += rte_crypto_uadk 88endif 89endif 90endif 91 92ifeq ($(findstring y,$(CONFIG_DPDK_COMPRESSDEV)$(CONFIG_VBDEV_COMPRESS)),y) 93DPDK_FRAMEWORK=y 94ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_compress_isal.*)) 95DPDK_LIB_LIST += rte_compress_isal 96endif 97ifeq ($(CONFIG_VBDEV_COMPRESS_MLX5),y) 98DPDK_LIB_LIST += rte_compress_mlx5 99endif 100ifeq ($(CONFIG_DPDK_UADK),y) 101ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_compress_uadk.*)) 102DPDK_LIB_LIST += rte_compress_uadk 103endif 104endif 105endif 106 107ifeq ($(DPDK_FRAMEWORK),y) 108DPDK_LIB_LIST += rte_cryptodev rte_compressdev rte_bus_vdev 109DPDK_LIB_LIST += rte_common_qat 110endif 111 112LINK_HASH=n 113 114ifeq ($(CONFIG_VHOST),y) 115DPDK_LIB_LIST += rte_vhost rte_net 116ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_dmadev.*)) 117# Introduced in DPDK 21.11, and rte_vhost became dependent on 118# it shortly thereafter 119DPDK_LIB_LIST += rte_dmadev 120endif 121LINK_HASH=y 122ifneq ($(DPDK_FRAMEWORK),y) 123DPDK_LIB_LIST += rte_cryptodev 124endif 125endif 126 127ifeq ($(CONFIG_FC),y) 128LINK_HASH=y 129endif 130 131ifeq ($(LINK_HASH),y) 132DPDK_LIB_LIST += rte_hash 133endif 134 135ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_log.*)) 136# Since DPDK 23.11.0-rc0 logging functions are in a separate library 137DPDK_LIB_LIST += rte_log 138endif 139 140DPDK_LIB_LIST_SORTED = $(sort $(DPDK_LIB_LIST)) 141 142DPDK_SHARED_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.so) 143DPDK_STATIC_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.a) 144DPDK_SHARED_LIB_LINKER_ARGS = $(call add_no_as_needed,$(DPDK_SHARED_LIB)) -Wl,-rpath=$(DPDK_LIB_DIR) 145DPDK_STATIC_LIB_LINKER_ARGS = $(call add_whole_archive,$(DPDK_STATIC_LIB)) 146 147ENV_CFLAGS = $(DPDK_INC) -DALLOW_EXPERIMENTAL_API 148ENV_CXXFLAGS = $(ENV_CFLAGS) 149 150DPDK_PRIVATE_LINKER_ARGS = 151 152ifeq ($(CONFIG_IPSEC_MB),y) 153DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB 154ifneq ($(IPSEC_MB_DIR),) 155DPDK_PRIVATE_LINKER_ARGS += -L$(IPSEC_MB_DIR) 156endif 157endif 158 159ifeq ($(CONFIG_HAVE_LIBBSD),y) 160DPDK_PRIVATE_LINKER_ARGS += -lbsd 161endif 162 163ifeq ($(CONFIG_HAVE_LIBARCHIVE),y) 164DPDK_PRIVATE_LINKER_ARGS += -larchive 165endif 166 167ifeq ($(CONFIG_CRYPTO),y) 168ifeq ($(CONFIG_CRYPTO_MLX5),y) 169DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 170endif 171endif 172 173ifeq ($(CONFIG_VBDEV_COMPRESS),y) 174DPDK_PRIVATE_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs 175ifeq ($(CONFIG_VBDEV_COMPRESS_MLX5),y) 176DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 177endif 178endif 179 180ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_config.h)) 181ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_config.h)) 182DPDK_PRIVATE_LINKER_ARGS += -lnuma 183endif 184endif 185 186# DPDK built with meson puts those defines elsewhere 187ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_build_config.h)) 188ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_build_config.h)) 189DPDK_PRIVATE_LINKER_ARGS += -lnuma 190endif 191endif 192 193ifeq ($(OS),Linux) 194DPDK_PRIVATE_LINKER_ARGS += -ldl 195endif 196ifeq ($(OS),FreeBSD) 197DPDK_PRIVATE_LINKER_ARGS += -lexecinfo 198endif 199 200ifeq ($(CC_TYPE),gcc) 201GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) 202ifeq ($(shell test $(GCC_MAJOR) -ge 10 && echo 1), 1) 203#1. gcc 10 complains on operations with zero size arrays in rte_cryptodev.c, so 204#disable this warning 205#2. gcc 10 disables fcommon by default and complains on multiple definition of 206#aesni_mb_logtype_driver symbol which is defined in header file and presented in several 207#translation units 208DPDK_CFLAGS += -Wno-stringop-overflow -fcommon 209ifeq ($(CONFIG_LTO),y) 210DPDK_LDFLAGS += -Wno-stringop-overflow -fcommon 211endif 212 213ifeq ($(shell test $(GCC_MAJOR) -ge 12 && echo 1), 1) 214# 3. gcc 12 reports reading incorrect size from a region. Seems like false positive, 215# see issue #2460 216DPDK_CFLAGS += -Wno-stringop-overread 217# 4. gcc 12 reports array subscript * is outside array bounds. Seems like false positive, 218# see issue #2668 219DPDK_CFLAGS += -Wno-array-bounds 220ifeq ($(CONFIG_LTO),y) 221DPDK_LDFLAGS += -Wno-stringop-overread -Wno-array-bounds 222endif 223 224endif 225endif 226endif 227 228ifeq ($(CONFIG_SHARED),y) 229ENV_DPDK_FILE = $(call spdk_lib_list_to_shared_libs,env_dpdk) 230ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_SHARED_LIB) 231DPDK_LINKER_ARGS = $(DPDK_SHARED_LIB_LINKER_ARGS) $(DPDK_LDFLAGS) 232ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 233else 234ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk) 235ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_STATIC_LIB) 236DPDK_LINKER_ARGS = $(DPDK_STATIC_LIB_LINKER_ARGS) $(DPDK_LDFLAGS) 237ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 238ENV_LINKER_ARGS += $(DPDK_PRIVATE_LINKER_ARGS) 239endif 240ENV_DEPLIBS += $(DEPDIRS-env_dpdk) 241