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 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 rte_rcu 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, compress 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_VBDEV_COMPRESS_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 ($(findstring y,$(CONFIG_DPDK_COMPRESSDEV)$(CONFIG_VBDEV_COMPRESS)),y) 84DPDK_FRAMEWORK=y 85ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_compress_isal.*)) 86DPDK_LIB_LIST += rte_compress_isal 87endif 88ifeq ($(CONFIG_VBDEV_COMPRESS_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 119endif 120 121ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_log.*)) 122# Since DPDK 23.11.0-rc0 logging functions are in a separate library 123DPDK_LIB_LIST += rte_log 124endif 125 126DPDK_LIB_LIST_SORTED = $(sort $(DPDK_LIB_LIST)) 127 128DPDK_SHARED_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.so) 129DPDK_STATIC_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.a) 130DPDK_SHARED_LIB_LINKER_ARGS = $(call add_no_as_needed,$(DPDK_SHARED_LIB)) -Wl,-rpath=$(DPDK_LIB_DIR) 131DPDK_STATIC_LIB_LINKER_ARGS = $(call add_whole_archive,$(DPDK_STATIC_LIB)) 132 133ENV_CFLAGS = $(DPDK_INC) -DALLOW_EXPERIMENTAL_API 134ENV_CXXFLAGS = $(ENV_CFLAGS) 135 136DPDK_PRIVATE_LINKER_ARGS = 137 138ifeq ($(CONFIG_IPSEC_MB),y) 139DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB 140ifneq ($(IPSEC_MB_DIR),) 141DPDK_PRIVATE_LINKER_ARGS += -L$(IPSEC_MB_DIR) 142endif 143endif 144 145ifeq ($(CONFIG_HAVE_LIBBSD),y) 146DPDK_PRIVATE_LINKER_ARGS += -lbsd 147endif 148 149ifeq ($(CONFIG_HAVE_LIBARCHIVE),y) 150DPDK_PRIVATE_LINKER_ARGS += -larchive 151endif 152 153ifeq ($(CONFIG_CRYPTO),y) 154ifeq ($(CONFIG_CRYPTO_MLX5),y) 155DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 156endif 157endif 158 159ifeq ($(CONFIG_VBDEV_COMPRESS),y) 160DPDK_PRIVATE_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs 161ifeq ($(CONFIG_VBDEV_COMPRESS_MLX5),y) 162DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs 163endif 164endif 165 166ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_config.h)) 167ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_config.h)) 168DPDK_PRIVATE_LINKER_ARGS += -lnuma 169endif 170endif 171 172# DPDK built with meson puts those defines elsewhere 173ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_build_config.h)) 174ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_build_config.h)) 175DPDK_PRIVATE_LINKER_ARGS += -lnuma 176endif 177endif 178 179ifeq ($(OS),Linux) 180DPDK_PRIVATE_LINKER_ARGS += -ldl 181endif 182ifeq ($(OS),FreeBSD) 183DPDK_PRIVATE_LINKER_ARGS += -lexecinfo 184endif 185 186ifeq ($(CONFIG_SHARED),y) 187ENV_DPDK_FILE = $(call spdk_lib_list_to_shared_libs,env_dpdk) 188ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_SHARED_LIB) 189DPDK_LINKER_ARGS = $(DPDK_SHARED_LIB_LINKER_ARGS) 190ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 191else 192ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk) 193ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_STATIC_LIB) 194DPDK_LINKER_ARGS = $(DPDK_STATIC_LIB_LINKER_ARGS) 195ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS) 196ENV_LINKER_ARGS += $(DPDK_PRIVATE_LINKER_ARGS) 197endif 198