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 100endif 101 102ifeq ($(DPDK_FRAMEWORK),y) 103DPDK_LIB_LIST += rte_cryptodev rte_compressdev rte_bus_vdev 104DPDK_LIB_LIST += rte_common_qat 105endif 106 107LINK_HASH=n 108 109ifeq ($(CONFIG_VHOST),y) 110DPDK_LIB_LIST += rte_vhost rte_net 111ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_dmadev.*)) 112# Introduced in DPDK 21.11, and rte_vhost became dependent on 113# it shortly thereafter 114DPDK_LIB_LIST += rte_dmadev 115endif 116LINK_HASH=y 117ifneq ($(DPDK_FRAMEWORK),y) 118DPDK_LIB_LIST += rte_cryptodev 119endif 120endif 121 122ifeq ($(CONFIG_FC),y) 123LINK_HASH=y 124endif 125 126ifeq ($(LINK_HASH),y) 127DPDK_LIB_LIST += rte_hash 128endif 129 130ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_log.*)) 131# Since DPDK 23.11.0-rc0 logging functions are in a separate library 132DPDK_LIB_LIST += rte_log 133endif 134 135DPDK_LIB_LIST_SORTED = $(sort $(DPDK_LIB_LIST)) 136 137DPDK_SHARED_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.so) 138DPDK_STATIC_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.a) 139DPDK_SHARED_LIB_LINKER_ARGS = $(call add_no_as_needed,$(DPDK_SHARED_LIB)) -Wl,-rpath=$(DPDK_LIB_DIR) 140DPDK_STATIC_LIB_LINKER_ARGS = $(call add_whole_archive,$(DPDK_STATIC_LIB)) 141 142ENV_CFLAGS = $(DPDK_INC) -DALLOW_EXPERIMENTAL_API 143ENV_CXXFLAGS = $(ENV_CFLAGS) 144 145DPDK_PRIVATE_LINKER_ARGS = 146 147ifeq ($(CONFIG_IPSEC_MB),y) 148DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB 149ifneq ($(IPSEC_MB_DIR),) 150DPDK_PRIVATE_LINKER_ARGS += -L$(IPSEC_MB_DIR) 151endif 152endif 153 154ifeq ($(CONFIG_HAVE_LIBBSD),y) 155DPDK_PRIVATE_LINKER_ARGS += -lbsd 156endif 157 158ifeq ($(CONFIG_HAVE_LIBARCHIVE),y) 159DPDK_PRIVATE_LINKER_ARGS += -larchive 160endif 161 162ifeq ($(CONFIG_CRYPTO),y) 163ifeq ($(CONFIG_CRYPTO_MLX5),y) 164DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 165endif 166endif 167 168ifeq ($(CONFIG_VBDEV_COMPRESS),y) 169DPDK_PRIVATE_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs 170ifeq ($(CONFIG_VBDEV_COMPRESS_MLX5),y) 171DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 172endif 173endif 174 175ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_config.h)) 176ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_config.h)) 177DPDK_PRIVATE_LINKER_ARGS += -lnuma 178endif 179endif 180 181# DPDK built with meson puts those defines elsewhere 182ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_build_config.h)) 183ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_build_config.h)) 184DPDK_PRIVATE_LINKER_ARGS += -lnuma 185endif 186endif 187 188ifeq ($(OS),Linux) 189DPDK_PRIVATE_LINKER_ARGS += -ldl 190endif 191ifeq ($(OS),FreeBSD) 192DPDK_PRIVATE_LINKER_ARGS += -lexecinfo 193endif 194 195ifeq ($(CC_TYPE),gcc) 196GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) 197ifeq ($(shell test $(GCC_MAJOR) -ge 10 && echo 1), 1) 198#1. gcc 10 complains on operations with zero size arrays in rte_cryptodev.c, so 199#disable this warning 200#2. gcc 10 disables fcommon by default and complains on multiple definition of 201#aesni_mb_logtype_driver symbol which is defined in header file and presented in several 202#translation units 203DPDK_CFLAGS += -Wno-stringop-overflow -fcommon 204ifeq ($(CONFIG_LTO),y) 205DPDK_LDFLAGS += -Wno-stringop-overflow -fcommon 206endif 207 208ifeq ($(shell test $(GCC_MAJOR) -ge 12 && echo 1), 1) 209# 3. gcc 12 reports reading incorect size from a region. Seems like false positive, 210# see issue #2460 211DPDK_CFLAGS += -Wno-stringop-overread 212# 4. gcc 12 reports array subscript * is outside array bounds. Seems like false positive, 213# see issue #2668 214DPDK_CFLAGS += -Wno-array-bounds 215ifeq ($(CONFIG_LTO),y) 216DPDK_LDFLAGS += -Wno-stringop-overread -Wno-array-bounds 217endif 218 219endif 220endif 221endif 222 223ifeq ($(CONFIG_SHARED),y) 224ENV_DPDK_FILE = $(call spdk_lib_list_to_shared_libs,env_dpdk) 225ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_SHARED_LIB) 226DPDK_LINKER_ARGS = $(DPDK_SHARED_LIB_LINKER_ARGS) $(DPDK_LDFLAGS) 227ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 228else 229ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk) 230ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_STATIC_LIB) 231DPDK_LINKER_ARGS = $(DPDK_STATIC_LIB_LINKER_ARGS) $(DPDK_LDFLAGS) 232ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 233ENV_LINKER_ARGS += $(DPDK_PRIVATE_LINKER_ARGS) 234endif 235ENV_DEPLIBS += $(DEPDIRS-env_dpdk) 236