xref: /spdk/lib/env_dpdk/env.mk (revision 2e1d23f4b70ea8940db7624b3bb974a4a8658ec7)
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
51# rte_power drivers, available since 24.11.0
52ifneq ($(wildcard $(DPDK_LIB_DIR)/librte_power_*),)
53DPDK_LIB_LIST += rte_power_acpi rte_power_amd_pstate rte_power_cppc rte_power_intel_pstate \
54		 rte_power_intel_uncore rte_power_kvm_vm
55endif
56endif
57endif
58
59# There are some complex dependencies when using crypto, compress or both so
60# here we add the feature specific ones and set a flag to add the common
61# ones after that.
62DPDK_FRAMEWORK=n
63
64ifeq ($(findstring y,$(CONFIG_CRYPTO_MLX5)$(CONFIG_VBDEV_COMPRESS_MLX5)),y)
65DPDK_LIB_LIST += rte_common_mlx5
66# Introduced in DPDK 21.08
67ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_bus_auxiliary.*))
68DPDK_LIB_LIST += rte_bus_auxiliary
69endif
70endif
71
72ifeq ($(CONFIG_CRYPTO),y)
73DPDK_FRAMEWORK=y
74ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_ipsec_mb.*))
75# PMD name as of DPDK 21.11
76DPDK_LIB_LIST += rte_crypto_ipsec_mb
77else
78ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_aesni_mb.*))
79# PMD name for DPDK 21.08 and earlier
80DPDK_LIB_LIST += rte_crypto_aesni_mb
81endif
82endif
83
84ifeq ($(CONFIG_CRYPTO_MLX5),y)
85ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_mlx5.*))
86DPDK_LIB_LIST += rte_crypto_mlx5
87endif
88endif
89
90ifeq ($(CONFIG_DPDK_UADK),y)
91ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_uadk.*))
92DPDK_LIB_LIST += rte_crypto_uadk
93endif
94endif
95endif
96
97ifeq ($(findstring y,$(CONFIG_DPDK_COMPRESSDEV)$(CONFIG_VBDEV_COMPRESS)),y)
98DPDK_FRAMEWORK=y
99ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_compress_isal.*))
100DPDK_LIB_LIST += rte_compress_isal
101endif
102ifeq ($(CONFIG_VBDEV_COMPRESS_MLX5),y)
103DPDK_LIB_LIST += rte_compress_mlx5
104endif
105ifeq ($(CONFIG_DPDK_UADK),y)
106ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_compress_uadk.*))
107DPDK_LIB_LIST += rte_compress_uadk
108endif
109endif
110endif
111
112ifeq ($(DPDK_FRAMEWORK),y)
113DPDK_LIB_LIST += rte_cryptodev rte_compressdev rte_bus_vdev
114DPDK_LIB_LIST += rte_common_qat
115endif
116
117LINK_HASH=n
118
119ifeq ($(CONFIG_VHOST),y)
120DPDK_LIB_LIST += rte_vhost rte_net
121ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_dmadev.*))
122# Introduced in DPDK 21.11, and rte_vhost became dependent on
123# it shortly thereafter
124DPDK_LIB_LIST += rte_dmadev
125endif
126LINK_HASH=y
127ifneq ($(DPDK_FRAMEWORK),y)
128DPDK_LIB_LIST += rte_cryptodev
129endif
130endif
131
132ifeq ($(CONFIG_FC),y)
133LINK_HASH=y
134endif
135
136ifeq ($(LINK_HASH),y)
137DPDK_LIB_LIST += rte_hash
138endif
139
140ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_log.*))
141# Since DPDK 23.11.0-rc0 logging functions are in a separate library
142DPDK_LIB_LIST += rte_log
143endif
144
145DPDK_LIB_LIST_SORTED = $(sort $(DPDK_LIB_LIST))
146
147DPDK_SHARED_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.so)
148DPDK_STATIC_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.a)
149DPDK_SHARED_LIB_LINKER_ARGS = $(call add_no_as_needed,$(DPDK_SHARED_LIB)) -Wl,-rpath=$(DPDK_LIB_DIR)
150DPDK_STATIC_LIB_LINKER_ARGS = $(call add_whole_archive,$(DPDK_STATIC_LIB))
151
152ENV_CFLAGS = $(DPDK_INC) -DALLOW_EXPERIMENTAL_API
153ENV_CXXFLAGS = $(ENV_CFLAGS)
154
155DPDK_PRIVATE_LINKER_ARGS =
156
157ifeq ($(CONFIG_IPSEC_MB),y)
158DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB
159ifneq ($(IPSEC_MB_DIR),)
160DPDK_PRIVATE_LINKER_ARGS += -L$(IPSEC_MB_DIR)
161endif
162endif
163
164ifeq ($(CONFIG_HAVE_LIBBSD),y)
165DPDK_PRIVATE_LINKER_ARGS += -lbsd
166endif
167
168ifeq ($(CONFIG_HAVE_LIBARCHIVE),y)
169DPDK_PRIVATE_LINKER_ARGS += -larchive
170endif
171
172ifeq ($(CONFIG_CRYPTO),y)
173ifeq ($(CONFIG_CRYPTO_MLX5),y)
174DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs
175endif
176endif
177
178ifeq ($(CONFIG_VBDEV_COMPRESS),y)
179DPDK_PRIVATE_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs
180ifeq ($(CONFIG_VBDEV_COMPRESS_MLX5),y)
181DPDK_PRIVATE_LINKER_ARGS += -lmlx5 -libverbs
182endif
183endif
184
185ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_config.h))
186ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_config.h))
187DPDK_PRIVATE_LINKER_ARGS += -lnuma
188endif
189endif
190
191# DPDK built with meson puts those defines elsewhere
192ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_build_config.h))
193ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_build_config.h))
194DPDK_PRIVATE_LINKER_ARGS += -lnuma
195endif
196endif
197
198ifeq ($(OS),Linux)
199DPDK_PRIVATE_LINKER_ARGS += -ldl
200endif
201ifeq ($(OS),FreeBSD)
202DPDK_PRIVATE_LINKER_ARGS += -lexecinfo
203endif
204
205ifeq ($(CC_TYPE),gcc)
206GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1)
207ifeq ($(shell test $(GCC_MAJOR) -ge 10 && echo 1), 1)
208#1. gcc 10 complains on operations with zero size arrays in rte_cryptodev.c, so
209#disable this warning
210#2. gcc 10 disables fcommon by default and complains on multiple definition of
211#aesni_mb_logtype_driver symbol which is defined in header file and presented in several
212#translation units
213DPDK_CFLAGS += -Wno-stringop-overflow -fcommon
214ifeq ($(CONFIG_LTO),y)
215DPDK_LDFLAGS += -Wno-stringop-overflow -fcommon
216endif
217
218ifeq ($(shell test $(GCC_MAJOR) -ge 12 && echo 1), 1)
219# 3. gcc 12 reports reading incorrect size from a region. Seems like false positive,
220# see issue #2460
221DPDK_CFLAGS += -Wno-stringop-overread
222# 4. gcc 12 reports array subscript * is outside array bounds. Seems like false positive,
223# see issue #2668
224DPDK_CFLAGS += -Wno-array-bounds
225ifeq ($(CONFIG_LTO),y)
226DPDK_LDFLAGS += -Wno-stringop-overread -Wno-array-bounds
227endif
228
229endif
230endif
231endif
232
233ifeq ($(CONFIG_SHARED),y)
234ENV_DPDK_FILE = $(call spdk_lib_list_to_shared_libs,env_dpdk)
235ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_SHARED_LIB)
236DPDK_LINKER_ARGS = $(DPDK_SHARED_LIB_LINKER_ARGS) $(DPDK_LDFLAGS)
237ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS)
238else
239ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk)
240ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_STATIC_LIB)
241DPDK_LINKER_ARGS = $(DPDK_STATIC_LIB_LINKER_ARGS) $(DPDK_LDFLAGS)
242ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS)
243ENV_LINKER_ARGS += $(DPDK_PRIVATE_LINKER_ARGS)
244endif
245ENV_DEPLIBS += $(DEPDIRS-env_dpdk)
246