1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright (c) 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 13DPDK_DIR = $(CONFIG_DPDK_DIR) 14 15export DPDK_ABS_DIR = $(abspath $(DPDK_DIR)) 16 17ifneq ($(CONFIG_DPDK_LIB_DIR),) 18DPDK_LIB_DIR = $(CONFIG_DPDK_LIB_DIR) 19else 20DPDK_LIB_DIR = $(DPDK_ABS_DIR)/lib 21endif 22 23ifneq ($(CONFIG_DPDK_INC_DIR),) 24DPDK_INC_DIR = $(CONFIG_DPDK_INC_DIR) 25else 26ifneq (, $(wildcard $(DPDK_ABS_DIR)/include/rte_config.h)) 27DPDK_INC_DIR := $(DPDK_ABS_DIR)/include 28else 29DPDK_INC_DIR := $(DPDK_ABS_DIR)/include/dpdk 30endif 31endif 32 33DPDK_INC := -I$(DPDK_INC_DIR) 34 35DPDK_LIB_LIST = rte_eal rte_mempool rte_ring rte_mbuf rte_bus_pci rte_pci rte_mempool_ring 36DPDK_LIB_LIST += rte_telemetry rte_kvargs 37 38DPDK_POWER=n 39 40ifeq ($(OS),Linux) 41# Despite rte_power was added DPDK 1.6, 42# some DPDK packages do not include it. See #2534. 43ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_power.*)) 44DPDK_POWER=y 45# Since DPDK 21.02 rte_power depends on rte_ethdev that 46# in turn depends on rte_net. 47DPDK_LIB_LIST += rte_power rte_ethdev rte_net 48endif 49endif 50 51# There are some complex dependencies when using crypto, reduce or both so 52# here we add the feature specific ones and set a flag to add the common 53# ones after that. 54DPDK_FRAMEWORK=n 55 56ifeq ($(findstring y,$(CONFIG_CRYPTO_MLX5)$(CONFIG_REDUCE_MLX5)),y) 57DPDK_LIB_LIST += rte_common_mlx5 58# Introduced in DPDK 21.08 59ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_bus_auxiliary.*)) 60DPDK_LIB_LIST += rte_bus_auxiliary 61endif 62endif 63 64ifeq ($(CONFIG_CRYPTO),y) 65DPDK_FRAMEWORK=y 66ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_ipsec_mb.*)) 67# PMD name as of DPDK 21.11 68DPDK_LIB_LIST += rte_crypto_ipsec_mb 69else 70ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_aesni_mb.*)) 71# PMD name for DPDK 21.08 and earlier 72DPDK_LIB_LIST += rte_crypto_aesni_mb 73endif 74endif 75 76ifeq ($(CONFIG_CRYPTO_MLX5),y) 77ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_mlx5.*)) 78DPDK_LIB_LIST += rte_crypto_mlx5 79endif 80endif 81endif 82 83ifeq ($(CONFIG_REDUCE),y) 84DPDK_FRAMEWORK=y 85ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_compress_isal.*)) 86DPDK_LIB_LIST += rte_compress_isal 87endif 88ifeq ($(CONFIG_REDUCE_MLX5),y) 89DPDK_LIB_LIST += rte_compress_mlx5 90endif 91endif 92 93ifeq ($(DPDK_FRAMEWORK),y) 94DPDK_LIB_LIST += rte_cryptodev rte_compressdev rte_bus_vdev 95DPDK_LIB_LIST += rte_common_qat 96endif 97 98LINK_HASH=n 99 100ifeq ($(CONFIG_VHOST),y) 101DPDK_LIB_LIST += rte_vhost rte_net 102ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_dmadev.*)) 103# Introduced in DPDK 21.11, and rte_vhost became dependent on 104# it shortly thereafter 105DPDK_LIB_LIST += rte_dmadev 106endif 107LINK_HASH=y 108ifneq ($(DPDK_FRAMEWORK),y) 109DPDK_LIB_LIST += rte_cryptodev 110endif 111endif 112 113ifeq ($(CONFIG_FC),y) 114LINK_HASH=y 115endif 116 117ifeq ($(LINK_HASH),y) 118DPDK_LIB_LIST += rte_hash 119ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_rcu.*)) 120DPDK_LIB_LIST += rte_rcu 121endif 122endif 123 124 125DPDK_LIB_LIST_SORTED = $(sort $(DPDK_LIB_LIST)) 126 127DPDK_SHARED_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.so) 128DPDK_STATIC_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.a) 129DPDK_SHARED_LIB_LINKER_ARGS = $(call add_no_as_needed,$(DPDK_SHARED_LIB)) 130DPDK_STATIC_LIB_LINKER_ARGS = $(call add_whole_archive,$(DPDK_STATIC_LIB)) 131 132ENV_CFLAGS = $(DPDK_INC) -DALLOW_EXPERIMENTAL_API 133ENV_CXXFLAGS = $(ENV_CFLAGS) 134 135DPDK_PRIVATE_LINKER_ARGS = 136 137ifeq ($(CONFIG_IPSEC_MB),y) 138DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB 139ifneq ($(IPSEC_MB_DIR),) 140DPDK_PRIVATE_LINKER_ARGS += -L$(IPSEC_MB_DIR) 141endif 142endif 143 144ifeq ($(CONFIG_HAVE_LIBBSD),y) 145DPDK_PRIVATE_LINKER_ARGS += -lbsd 146endif 147 148ifeq ($(CONFIG_CRYPTO),y) 149ifeq ($(CONFIG_CRYPTO_MLX5),y) 150DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 151endif 152endif 153 154ifeq ($(CONFIG_REDUCE),y) 155DPDK_PRIVATE_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs 156ifeq ($(CONFIG_REDUCE_MLX5),y) 157DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 158endif 159endif 160 161ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_config.h)) 162ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_config.h)) 163DPDK_PRIVATE_LINKER_ARGS += -lnuma 164endif 165endif 166 167# DPDK built with meson puts those defines elsewhere 168ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_build_config.h)) 169ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_build_config.h)) 170DPDK_PRIVATE_LINKER_ARGS += -lnuma 171endif 172endif 173 174ifeq ($(OS),Linux) 175DPDK_PRIVATE_LINKER_ARGS += -ldl 176endif 177ifeq ($(OS),FreeBSD) 178DPDK_PRIVATE_LINKER_ARGS += -lexecinfo 179endif 180 181ifeq ($(CONFIG_SHARED),y) 182ENV_DPDK_FILE = $(call spdk_lib_list_to_shared_libs,env_dpdk) 183ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_SHARED_LIB) 184DPDK_LINKER_ARGS = $(DPDK_SHARED_LIB_LINKER_ARGS) 185ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 186else 187ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk) 188ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_STATIC_LIB) 189DPDK_LINKER_ARGS = $(DPDK_STATIC_LIB_LINKER_ARGS) 190ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 191ENV_LINKER_ARGS += $(DPDK_PRIVATE_LINKER_ARGS) 192endif 193