1 # Copyright (c) 2020 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 DPDK_PKTMBUF_HEADROOM ?= 128
19 DPDK_MLX5_COMMON_PMD ?= n
21 DPDK_FAILSAFE_PMD ?= n
22 DPDK_MACHINE ?= default
23 DPDK_MLX_IBV_LINK ?= static
26 dpdk_base_url ?= http://fast.dpdk.org/rel
27 dpdk_tarball := dpdk-$(dpdk_version).tar.xz
28 dpdk_tarball_md5sum_22.03 := a07ca8839f98062f46e1cc359735cce8
29 dpdk_tarball_md5sum_21.11 := 58660bbbe9e95abce86e47692b196555
30 dpdk_tarball_md5sum_21.08 := de33433a1806280996a0ecbe66e3642f
31 dpdk_tarball_md5sum_21.05 := a78bba290b11d9717d1272cc6bfaf7c3
32 dpdk_tarball_md5sum := $(dpdk_tarball_md5sum_$(dpdk_version))
33 dpdk_url := $(dpdk_base_url)/$(dpdk_tarball)
34 dpdk_tarball_strip_dirs := 1
35 dpdk_depends := rdma-core $(if $(ARCH_X86_64), ipsec-mb)
38 DPDK_BUILD_TYPE:=release
39 ifeq ($(DPDK_DEBUG), y)
40 DPDK_BUILD_TYPE:=debug
43 DPDK_DRIVERS_DISABLED := baseband/\*, \
76 DPDK_LIBS_DISABLED := acl, \
102 DPDK_MLX_CONFIG_FLAG :=
104 # Adjust disabled pmd and libs depending on user provided variables
105 ifeq ($(DPDK_MLX4_PMD), n)
106 DPDK_DRIVERS_DISABLED += ,net/mlx4
108 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
110 ifeq ($(DPDK_MLX5_PMD), n)
111 DPDK_DRIVERS_DISABLED += ,net/mlx5
113 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
115 ifeq ($(DPDK_MLX5_COMMON_PMD), n)
116 DPDK_DRIVERS_DISABLED += ,common/mlx5
118 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
120 ifeq ($(DPDK_TAP_PMD), n)
121 DPDK_DRIVERS_DISABLED += ,net/tap
123 ifeq ($(DPDK_FAILSAFE_PMD), n)
124 DPDK_DRIVERS_DISABLED += ,net/failsafe
127 # Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
128 DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
129 DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
132 # post-meson-setup snippet to alter rte_build_config.h
134 if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then \
135 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
136 $(dpdk_src_dir)/config/rte_config.h; \
137 elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
138 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
139 $(dpdk_build_dir)/rte_build_config.h; \
141 echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
142 >> $(dpdk_build_dir)/rte_build_config.h ; \
146 define dpdk_config_def
147 if [[ "$(DPDK_$(1))" == "y" ]]; then \
148 if ! grep -q "RTE_$(1)" $(dpdk_build_dir)/rte_build_config.h \
149 $(dpdk_src_dir)/config/rte_config.h ; then \
150 echo '$(HASH)define RTE_$(1) 1' \
151 >> $(dpdk_build_dir)/rte_build_config.h ; \
153 elif [[ "$(DPDK_$(1))" == "n" ]]; then \
154 sed -i '/$(HASH)define RTE_$(1) .*/d' $(dpdk_build_dir)/rte_build_config.h \
155 $(dpdk_src_dir)/config/rte_config.h ; \
160 --default-library static \
162 --prefix $(dpdk_install_dir) \
164 "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
165 "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
167 -Dmachine=$(DPDK_MACHINE) \
168 --buildtype=$(DPDK_BUILD_TYPE) \
169 ${DPDK_MLX_CONFIG_FLAG}
171 PIP_DOWNLOAD_DIR = $(CURDIR)/downloads/
173 define dpdk_config_cmds
174 cd $(dpdk_build_dir) && \
175 rm -rf ../dpdk-meson-venv && \
176 mkdir -p ../dpdk-meson-venv && \
177 python3 -m venv ../dpdk-meson-venv && \
178 source ../dpdk-meson-venv/bin/activate && \
179 (if ! ls $(PIP_DOWNLOAD_DIR)meson* ; then pip3 download -d $(PIP_DOWNLOAD_DIR) -f $(DL_CACHE_DIR) meson==0.55 setuptools wheel pyelftools; fi) && \
180 pip3 install --no-index --find-links=$(PIP_DOWNLOAD_DIR) meson==0.55 pyelftools && \
181 PKG_CONFIG_PATH=$(dpdk_install_dir)/lib/pkgconfig meson setup $(dpdk_src_dir) \
184 | tee $(dpdk_config_log) && \
186 echo "DPDK post meson configuration" && \
187 echo "Altering rte_build_config.h" && \
188 $(call dpdk_config,PKTMBUF_HEADROOM) && \
189 $(call dpdk_config_def,USE_LIBBSD)
192 ifeq ("$(DPDK_VERBOSE)","1")
193 DPDK_VERBOSE_BUILD = --verbose
196 define dpdk_build_cmds
197 cd $(dpdk_build_dir) && \
198 source ../dpdk-meson-venv/bin/activate && \
199 meson compile $(DPDK_VERBOSE_BUILD) -C . | tee $(dpdk_build_log) && \
203 define dpdk_install_cmds
204 cd $(dpdk_build_dir) && \
205 source ../dpdk-meson-venv/bin/activate && \
207 cd $(dpdk_install_dir)/lib && \
208 echo "GROUP ( $$(ls librte*.a ) )" > libdpdk.a && \
209 rm -rf librte*.so librte*.so.* dpdk/*/librte*.so dpdk/*/librte*.so.* && \
213 $(eval $(call package,dpdk))