blob: 04a069bb179538126d6a7d0a96c7750a9fdce08d [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
Xinyao Caidf6a00f2023-05-09 21:29:30 +080022dpdk_version ?= 23.03
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020023dpdk_base_url ?= http://fast.dpdk.org/rel
24dpdk_tarball := dpdk-$(dpdk_version).tar.xz
Xinyao Caidf6a00f2023-05-09 21:29:30 +080025dpdk_tarball_md5sum_23.03 := 3cf8ebbcd412d5726db230f2eeb90cc9
Xinyao Caiefcf1be2023-04-27 09:29:44 +080026dpdk_tarball_md5sum_22.11.1 := 0594708fe42ce186a55b0235c6e20cfe
Fan Zhang3c285b52022-08-02 10:17:08 +000027dpdk_tarball_md5sum_22.07 := fb73b58b80b1349cd05fe9cf6984afd4
Dastin Wilski2f132ef2022-03-30 14:19:00 +020028dpdk_tarball_md5sum_22.03 := a07ca8839f98062f46e1cc359735cce8
Damjan Marion6c75cd22022-01-11 23:21:08 +010029dpdk_tarball_md5sum_21.11 := 58660bbbe9e95abce86e47692b196555
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020030dpdk_tarball_md5sum := $(dpdk_tarball_md5sum_$(dpdk_version))
31dpdk_url := $(dpdk_base_url)/$(dpdk_tarball)
32dpdk_tarball_strip_dirs := 1
Mohammed Hawarife909a62020-11-20 18:37:14 +010033dpdk_depends := rdma-core $(if $(ARCH_X86_64), ipsec-mb)
Mohammed Hawari4e939ce2022-09-19 16:26:25 +020034
35DPDK_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)
36DPDK_MLX4_PMD ?= $(DPDK_MLX_DEFAULT)
37DPDK_MLX5_PMD ?= $(DPDK_MLX_DEFAULT)
38DPDK_MLX5_COMMON_PMD ?= $(DPDK_MLX_DEFAULT)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020039# Debug or release
40
41DPDK_BUILD_TYPE:=release
42ifeq ($(DPDK_DEBUG), y)
43DPDK_BUILD_TYPE:=debug
Damjan Marion561f2732018-09-21 12:27:45 +020044endif
45
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020046DPDK_DRIVERS_DISABLED := baseband/\*, \
47 bus/dpaa, \
48 bus/ifpga, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040049 common/cnxk, \
Fan Zhang1152e602020-09-25 22:36:04 +010050 compress/isal, \
51 compress/octeontx, \
52 compress/zlib, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020053 crypto/ccp, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040054 crypto/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020055 crypto/dpaa_sec, \
56 crypto/openssl, \
PiotrX Kleski9235d432020-10-12 15:33:11 +020057 crypto/aesni_mb, \
58 crypto/aesni_gcm, \
59 crypto/kasumi, \
60 crypto/snow3g, \
61 crypto/zuc, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020062 event/\*, \
63 mempool/dpaa, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040064 mempool/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020065 net/af_packet, \
66 net/bnx2x, \
67 net/bonding, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040068 net/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020069 net/ipn3ke, \
70 net/liquidio, \
71 net/pcap, \
72 net/pfe, \
73 net/sfc, \
74 net/softnic, \
75 net/thunderx, \
76 raw/ifpga, \
Fan Zhang9303b102021-05-27 13:24:52 +010077 net/af_xdp
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020078
79DPDK_LIBS_DISABLED := acl, \
80 bbdev, \
81 bitratestats, \
82 bpf, \
83 cfgfile, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040084 cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020085 distributor, \
86 efd, \
87 fib, \
88 flow_classify, \
89 graph, \
90 gro, \
91 gso, \
92 jobstats, \
93 kni, \
94 latencystats, \
95 lpm, \
96 member, \
97 node, \
98 pipeline, \
99 port, \
100 power, \
101 rawdev, \
102 rib, \
103 table
104
Mohammed Hawarife909a62020-11-20 18:37:14 +0100105DPDK_MLX_CONFIG_FLAG :=
106
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200107# Adjust disabled pmd and libs depending on user provided variables
108ifeq ($(DPDK_MLX4_PMD), n)
109 DPDK_DRIVERS_DISABLED += ,net/mlx4
Mohammed Hawarife909a62020-11-20 18:37:14 +0100110else
111 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200112endif
113ifeq ($(DPDK_MLX5_PMD), n)
114 DPDK_DRIVERS_DISABLED += ,net/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100115else
116 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200117endif
118ifeq ($(DPDK_MLX5_COMMON_PMD), n)
119 DPDK_DRIVERS_DISABLED += ,common/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100120else
121 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200122endif
123ifeq ($(DPDK_TAP_PMD), n)
124 DPDK_DRIVERS_DISABLED += ,net/tap
125endif
126ifeq ($(DPDK_FAILSAFE_PMD), n)
127 DPDK_DRIVERS_DISABLED += ,net/failsafe
Damjan Marion561f2732018-09-21 12:27:45 +0200128endif
129
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200130# Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
131DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
132DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
Damjan Marion561f2732018-09-21 12:27:45 +0200133
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200134HASH := \#
135# post-meson-setup snippet to alter rte_build_config.h
136define dpdk_config
137if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then \
138sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
139 $(dpdk_src_dir)/config/rte_config.h; \
140elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
141sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
142 $(dpdk_build_dir)/rte_build_config.h; \
143else \
144echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
145 >> $(dpdk_build_dir)/rte_build_config.h ; \
Damjan Marion561f2732018-09-21 12:27:45 +0200146fi
147endef
148
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200149define dpdk_config_def
150if [[ "$(DPDK_$(1))" == "y" ]]; then \
151 if ! grep -q "RTE_$(1)" $(dpdk_build_dir)/rte_build_config.h \
152 $(dpdk_src_dir)/config/rte_config.h ; then \
153 echo '$(HASH)define RTE_$(1) 1' \
154 >> $(dpdk_build_dir)/rte_build_config.h ; \
155 fi; \
156elif [[ "$(DPDK_$(1))" == "n" ]]; then \
157 sed -i '/$(HASH)define RTE_$(1) .*/d' $(dpdk_build_dir)/rte_build_config.h \
158 $(dpdk_src_dir)/config/rte_config.h ; \
159fi
160endef
161
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200162DPDK_MESON_ARGS = \
163 --default-library static \
164 --libdir lib \
165 --prefix $(dpdk_install_dir) \
166 -Dtests=false \
Xinyao Caiefcf1be2023-04-27 09:29:44 +0800167 -Denable_driver_sdk=true \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200168 "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
169 "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
170 -Db_pie=true \
171 -Dmachine=$(DPDK_MACHINE) \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100172 --buildtype=$(DPDK_BUILD_TYPE) \
173 ${DPDK_MLX_CONFIG_FLAG}
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200174
175PIP_DOWNLOAD_DIR = $(CURDIR)/downloads/
Damjan Marion561f2732018-09-21 12:27:45 +0200176
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200177define dpdk_config_cmds
178 cd $(dpdk_build_dir) && \
Dave Wallace14b118b2022-10-04 23:48:44 -0400179 echo "DPDK_MLX_DEFAULT=$(DPDK_MLX_DEFAULT)" > ../../../dpdk_mlx_default.sh && \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200180 rm -rf ../dpdk-meson-venv && \
181 mkdir -p ../dpdk-meson-venv && \
182 python3 -m venv ../dpdk-meson-venv && \
183 source ../dpdk-meson-venv/bin/activate && \
Nick Brownae4ed322021-09-07 18:24:42 +0100184 (if ! ls $(PIP_DOWNLOAD_DIR)meson* ; then pip3 download -d $(PIP_DOWNLOAD_DIR) -f $(DL_CACHE_DIR) meson==0.55 setuptools wheel pyelftools; fi) && \
185 pip3 install --no-index --find-links=$(PIP_DOWNLOAD_DIR) meson==0.55 pyelftools && \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100186 PKG_CONFIG_PATH=$(dpdk_install_dir)/lib/pkgconfig meson setup $(dpdk_src_dir) \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200187 $(dpdk_build_dir) \
188 $(DPDK_MESON_ARGS) \
189 | tee $(dpdk_config_log) && \
190 deactivate && \
191 echo "DPDK post meson configuration" && \
192 echo "Altering rte_build_config.h" && \
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200193 $(call dpdk_config,PKTMBUF_HEADROOM) && \
194 $(call dpdk_config_def,USE_LIBBSD)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200195endef
BenoƮt Gannefe750c22019-03-25 11:41:34 +0100196
Nick Brownae4ed322021-09-07 18:24:42 +0100197ifeq ("$(DPDK_VERBOSE)","1")
198DPDK_VERBOSE_BUILD = --verbose
199endif
200
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200201define dpdk_build_cmds
202 cd $(dpdk_build_dir) && \
203 source ../dpdk-meson-venv/bin/activate && \
Nick Brownae4ed322021-09-07 18:24:42 +0100204 meson compile $(DPDK_VERBOSE_BUILD) -C . | tee $(dpdk_build_log) && \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200205 deactivate
206endef
Damjan Marion561f2732018-09-21 12:27:45 +0200207
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200208define dpdk_install_cmds
209 cd $(dpdk_build_dir) && \
210 source ../dpdk-meson-venv/bin/activate && \
211 meson install && \
212 cd $(dpdk_install_dir)/lib && \
213 echo "GROUP ( $$(ls librte*.a ) )" > libdpdk.a && \
214 rm -rf librte*.so librte*.so.* dpdk/*/librte*.so dpdk/*/librte*.so.* && \
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200215 deactivate
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200216endef
Damjan Marion561f2732018-09-21 12:27:45 +0200217
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200218$(eval $(call package,dpdk))