blob: 42ad74c3ec4ee44911c953ba7b3692048b7c0ca9 [file] [log] [blame]
Mohammed Hawari4c4633c2020-09-15 14:05:11 +02001# Copyright (c) 2020 Cisco and/or its affiliates.
Damjan Marion561f2732018-09-21 12:27:45 +02002# 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:
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
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.
13
14DPDK_PKTMBUF_HEADROOM ?= 128
Mohammed Hawari1f799bc2020-09-18 21:47:04 +020015DPDK_USE_LIBBSD ?= n
Damjan Marion561f2732018-09-21 12:27:45 +020016DPDK_DEBUG ?= n
Damjan Marion561f2732018-09-21 12:27:45 +020017DPDK_TAP_PMD ?= n
18DPDK_FAILSAFE_PMD ?= n
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020019DPDK_MACHINE ?= default
Mohammed Hawarife909a62020-11-20 18:37:14 +010020DPDK_MLX_IBV_LINK ?= static
Damjan Marion561f2732018-09-21 12:27:45 +020021
Kai Ji44218982023-08-08 23:46:12 +000022dpdk_version ?= 23.07
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020023dpdk_base_url ?= http://fast.dpdk.org/rel
24dpdk_tarball := dpdk-$(dpdk_version).tar.xz
Kai Ji44218982023-08-08 23:46:12 +000025dpdk_tarball_md5sum_23.07 := 2b6d57f077585cb15b885482362fd47f
Xinyao Caidf6a00f2023-05-09 21:29:30 +080026dpdk_tarball_md5sum_23.03 := 3cf8ebbcd412d5726db230f2eeb90cc9
Xinyao Caiefcf1be2023-04-27 09:29:44 +080027dpdk_tarball_md5sum_22.11.1 := 0594708fe42ce186a55b0235c6e20cfe
Fan Zhang3c285b52022-08-02 10:17:08 +000028dpdk_tarball_md5sum_22.07 := fb73b58b80b1349cd05fe9cf6984afd4
Dastin Wilski2f132ef2022-03-30 14:19:00 +020029dpdk_tarball_md5sum_22.03 := a07ca8839f98062f46e1cc359735cce8
Damjan Marion6c75cd22022-01-11 23:21:08 +010030dpdk_tarball_md5sum_21.11 := 58660bbbe9e95abce86e47692b196555
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020031dpdk_tarball_md5sum := $(dpdk_tarball_md5sum_$(dpdk_version))
32dpdk_url := $(dpdk_base_url)/$(dpdk_tarball)
33dpdk_tarball_strip_dirs := 1
Mohammed Hawarife909a62020-11-20 18:37:14 +010034dpdk_depends := rdma-core $(if $(ARCH_X86_64), ipsec-mb)
Mohammed Hawari4e939ce2022-09-19 16:26:25 +020035
36DPDK_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)
37DPDK_MLX4_PMD ?= $(DPDK_MLX_DEFAULT)
38DPDK_MLX5_PMD ?= $(DPDK_MLX_DEFAULT)
39DPDK_MLX5_COMMON_PMD ?= $(DPDK_MLX_DEFAULT)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020040# Debug or release
41
42DPDK_BUILD_TYPE:=release
43ifeq ($(DPDK_DEBUG), y)
44DPDK_BUILD_TYPE:=debug
Damjan Marion561f2732018-09-21 12:27:45 +020045endif
46
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020047DPDK_DRIVERS_DISABLED := baseband/\*, \
48 bus/dpaa, \
49 bus/ifpga, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040050 common/cnxk, \
Fan Zhang1152e602020-09-25 22:36:04 +010051 compress/isal, \
52 compress/octeontx, \
53 compress/zlib, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020054 crypto/ccp, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040055 crypto/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020056 crypto/dpaa_sec, \
57 crypto/openssl, \
PiotrX Kleski9235d432020-10-12 15:33:11 +020058 crypto/aesni_mb, \
59 crypto/aesni_gcm, \
60 crypto/kasumi, \
61 crypto/snow3g, \
62 crypto/zuc, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020063 event/\*, \
64 mempool/dpaa, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040065 mempool/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020066 net/af_packet, \
67 net/bnx2x, \
68 net/bonding, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040069 net/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020070 net/ipn3ke, \
71 net/liquidio, \
72 net/pcap, \
73 net/pfe, \
74 net/sfc, \
75 net/softnic, \
76 net/thunderx, \
77 raw/ifpga, \
Fan Zhang9303b102021-05-27 13:24:52 +010078 net/af_xdp
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020079
80DPDK_LIBS_DISABLED := acl, \
81 bbdev, \
82 bitratestats, \
83 bpf, \
84 cfgfile, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040085 cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020086 distributor, \
87 efd, \
88 fib, \
89 flow_classify, \
90 graph, \
91 gro, \
92 gso, \
93 jobstats, \
94 kni, \
95 latencystats, \
96 lpm, \
97 member, \
98 node, \
99 pipeline, \
100 port, \
101 power, \
102 rawdev, \
103 rib, \
104 table
105
Mohammed Hawarife909a62020-11-20 18:37:14 +0100106DPDK_MLX_CONFIG_FLAG :=
107
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200108# Adjust disabled pmd and libs depending on user provided variables
109ifeq ($(DPDK_MLX4_PMD), n)
110 DPDK_DRIVERS_DISABLED += ,net/mlx4
Mohammed Hawarife909a62020-11-20 18:37:14 +0100111else
112 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200113endif
114ifeq ($(DPDK_MLX5_PMD), n)
115 DPDK_DRIVERS_DISABLED += ,net/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100116else
117 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200118endif
119ifeq ($(DPDK_MLX5_COMMON_PMD), n)
120 DPDK_DRIVERS_DISABLED += ,common/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100121else
122 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200123endif
124ifeq ($(DPDK_TAP_PMD), n)
125 DPDK_DRIVERS_DISABLED += ,net/tap
126endif
127ifeq ($(DPDK_FAILSAFE_PMD), n)
128 DPDK_DRIVERS_DISABLED += ,net/failsafe
Damjan Marion561f2732018-09-21 12:27:45 +0200129endif
130
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200131# Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
132DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
133DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
Damjan Marion561f2732018-09-21 12:27:45 +0200134
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200135HASH := \#
136# post-meson-setup snippet to alter rte_build_config.h
137define dpdk_config
138if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then \
139sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
140 $(dpdk_src_dir)/config/rte_config.h; \
141elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
142sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
143 $(dpdk_build_dir)/rte_build_config.h; \
144else \
145echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
146 >> $(dpdk_build_dir)/rte_build_config.h ; \
Damjan Marion561f2732018-09-21 12:27:45 +0200147fi
148endef
149
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200150define dpdk_config_def
151if [[ "$(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 ; \
156 fi; \
157elif [[ "$(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 ; \
160fi
161endef
162
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200163DPDK_MESON_ARGS = \
164 --default-library static \
165 --libdir lib \
166 --prefix $(dpdk_install_dir) \
167 -Dtests=false \
Xinyao Caiefcf1be2023-04-27 09:29:44 +0800168 -Denable_driver_sdk=true \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200169 "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
170 "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
171 -Db_pie=true \
172 -Dmachine=$(DPDK_MACHINE) \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100173 --buildtype=$(DPDK_BUILD_TYPE) \
174 ${DPDK_MLX_CONFIG_FLAG}
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200175
176PIP_DOWNLOAD_DIR = $(CURDIR)/downloads/
Damjan Marion561f2732018-09-21 12:27:45 +0200177
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200178define dpdk_config_cmds
179 cd $(dpdk_build_dir) && \
Dave Wallace14b118b2022-10-04 23:48:44 -0400180 echo "DPDK_MLX_DEFAULT=$(DPDK_MLX_DEFAULT)" > ../../../dpdk_mlx_default.sh && \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200181 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 && \
Nick Brownae4ed322021-09-07 18:24:42 +0100185 (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 && \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100187 PKG_CONFIG_PATH=$(dpdk_install_dir)/lib/pkgconfig meson setup $(dpdk_src_dir) \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200188 $(dpdk_build_dir) \
189 $(DPDK_MESON_ARGS) \
190 | tee $(dpdk_config_log) && \
191 deactivate && \
192 echo "DPDK post meson configuration" && \
193 echo "Altering rte_build_config.h" && \
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200194 $(call dpdk_config,PKTMBUF_HEADROOM) && \
195 $(call dpdk_config_def,USE_LIBBSD)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200196endef
BenoƮt Gannefe750c22019-03-25 11:41:34 +0100197
Nick Brownae4ed322021-09-07 18:24:42 +0100198ifeq ("$(DPDK_VERBOSE)","1")
199DPDK_VERBOSE_BUILD = --verbose
200endif
201
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200202define dpdk_build_cmds
203 cd $(dpdk_build_dir) && \
204 source ../dpdk-meson-venv/bin/activate && \
Nick Brownae4ed322021-09-07 18:24:42 +0100205 meson compile $(DPDK_VERBOSE_BUILD) -C . | tee $(dpdk_build_log) && \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200206 deactivate
207endef
Damjan Marion561f2732018-09-21 12:27:45 +0200208
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200209define dpdk_install_cmds
210 cd $(dpdk_build_dir) && \
211 source ../dpdk-meson-venv/bin/activate && \
212 meson install && \
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.* && \
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200216 deactivate
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200217endef
Damjan Marion561f2732018-09-21 12:27:45 +0200218
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200219$(eval $(call package,dpdk))