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
18 DPDK_FAILSAFE_PMD ?= n
19 DPDK_MACHINE ?= default
20 DPDK_MLX_IBV_LINK ?= static
23 dpdk_base_url ?= http://fast.dpdk.org/rel
24 dpdk_tarball := dpdk-$(dpdk_version).tar.xz
25 dpdk_tarball_md5sum_23.07 := 2b6d57f077585cb15b885482362fd47f
26 dpdk_tarball_md5sum_23.03 := 3cf8ebbcd412d5726db230f2eeb90cc9
27 dpdk_tarball_md5sum_22.11.1 := 0594708fe42ce186a55b0235c6e20cfe
28 dpdk_tarball_md5sum_22.07 := fb73b58b80b1349cd05fe9cf6984afd4
29 dpdk_tarball_md5sum_22.03 := a07ca8839f98062f46e1cc359735cce8
30 dpdk_tarball_md5sum_21.11 := 58660bbbe9e95abce86e47692b196555
31 dpdk_tarball_md5sum := $(dpdk_tarball_md5sum_$(dpdk_version))
32 dpdk_url := $(dpdk_base_url)/$(dpdk_tarball)
33 dpdk_tarball_strip_dirs := 1
34 dpdk_depends := rdma-core $(if $(ARCH_X86_64), ipsec-mb)
36 DPDK_MLX_DEFAULT := $(shell if grep -q "rdma=$(rdma-core_version) dpdk=$(dpdk_version)" mlx_rdma_dpdk_matrix.txt; then echo 'y'; else echo 'n'; fi)
37 DPDK_MLX4_PMD ?= $(DPDK_MLX_DEFAULT)
38 DPDK_MLX5_PMD ?= $(DPDK_MLX_DEFAULT)
39 DPDK_MLX5_COMMON_PMD ?= $(DPDK_MLX_DEFAULT)
42 DPDK_BUILD_TYPE:=release
43 ifeq ($(DPDK_DEBUG), y)
44 DPDK_BUILD_TYPE:=debug
47 DPDK_DRIVERS_DISABLED := baseband/\*, \
80 DPDK_LIBS_DISABLED := acl, \
106 DPDK_MLX_CONFIG_FLAG :=
108 # Adjust disabled pmd and libs depending on user provided variables
109 ifeq ($(DPDK_MLX4_PMD), n)
110 DPDK_DRIVERS_DISABLED += ,net/mlx4
112 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
114 ifeq ($(DPDK_MLX5_PMD), n)
115 DPDK_DRIVERS_DISABLED += ,net/mlx5
117 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
119 ifeq ($(DPDK_MLX5_COMMON_PMD), n)
120 DPDK_DRIVERS_DISABLED += ,common/mlx5
122 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
124 ifeq ($(DPDK_TAP_PMD), n)
125 DPDK_DRIVERS_DISABLED += ,net/tap
127 ifeq ($(DPDK_FAILSAFE_PMD), n)
128 DPDK_DRIVERS_DISABLED += ,net/failsafe
131 # Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
132 DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
133 DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
136 # post-meson-setup snippet to alter rte_build_config.h
138 if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then \
139 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
140 $(dpdk_src_dir)/config/rte_config.h; \
141 elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
142 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
143 $(dpdk_build_dir)/rte_build_config.h; \
145 echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
146 >> $(dpdk_build_dir)/rte_build_config.h ; \
150 define dpdk_config_def
151 if [[ "$(DPDK_$(1))" == "y" ]]; then \
152 if ! grep -q "RTE_$(1)" $(dpdk_build_dir)/rte_build_config.h \
153 $(dpdk_src_dir)/config/rte_config.h ; then \
154 echo '$(HASH)define RTE_$(1) 1' \
155 >> $(dpdk_build_dir)/rte_build_config.h ; \
157 elif [[ "$(DPDK_$(1))" == "n" ]]; then \
158 sed -i '/$(HASH)define RTE_$(1) .*/d' $(dpdk_build_dir)/rte_build_config.h \
159 $(dpdk_src_dir)/config/rte_config.h ; \
164 --default-library static \
166 --prefix $(dpdk_install_dir) \
168 -Denable_driver_sdk=true \
169 "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
170 "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
172 -Dmachine=$(DPDK_MACHINE) \
173 --buildtype=$(DPDK_BUILD_TYPE) \
174 ${DPDK_MLX_CONFIG_FLAG}
176 PIP_DOWNLOAD_DIR = $(CURDIR)/downloads/
178 define dpdk_config_cmds
179 cd $(dpdk_build_dir) && \
180 echo "DPDK_MLX_DEFAULT=$(DPDK_MLX_DEFAULT)" > ../../../dpdk_mlx_default.sh && \
181 rm -rf ../dpdk-meson-venv && \
182 mkdir -p ../dpdk-meson-venv && \
183 python3 -m venv ../dpdk-meson-venv && \
184 source ../dpdk-meson-venv/bin/activate && \
185 (if ! ls $(PIP_DOWNLOAD_DIR)meson* ; then pip3 download -d $(PIP_DOWNLOAD_DIR) -f $(DL_CACHE_DIR) meson==0.55 setuptools wheel pyelftools; fi) && \
186 pip3 install --no-index --find-links=$(PIP_DOWNLOAD_DIR) meson==0.55 pyelftools && \
187 PKG_CONFIG_PATH=$(dpdk_install_dir)/lib/pkgconfig meson setup $(dpdk_src_dir) \
190 | tee $(dpdk_config_log) && \
192 echo "DPDK post meson configuration" && \
193 echo "Altering rte_build_config.h" && \
194 $(call dpdk_config,PKTMBUF_HEADROOM) && \
195 $(call dpdk_config_def,USE_LIBBSD)
198 ifeq ("$(DPDK_VERBOSE)","1")
199 DPDK_VERBOSE_BUILD = --verbose
202 define dpdk_build_cmds
203 cd $(dpdk_build_dir) && \
204 source ../dpdk-meson-venv/bin/activate && \
205 meson compile $(DPDK_VERBOSE_BUILD) -C . | tee $(dpdk_build_log) && \
209 define dpdk_install_cmds
210 cd $(dpdk_build_dir) && \
211 source ../dpdk-meson-venv/bin/activate && \
213 cd $(dpdk_install_dir)/lib && \
214 echo "GROUP ( $$(ls librte*.a ) )" > libdpdk.a && \
215 rm -rf librte*.so librte*.so.* dpdk/*/librte*.so dpdk/*/librte*.so.* && \
219 $(eval $(call package,dpdk))