blob: e0558f3e474cc7b3a57667fabfd4d8636adb0744 [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
17DPDK_MLX4_PMD ?= n
18DPDK_MLX5_PMD ?= n
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020019DPDK_MLX5_COMMON_PMD ?= n
Damjan Marion561f2732018-09-21 12:27:45 +020020DPDK_TAP_PMD ?= n
21DPDK_FAILSAFE_PMD ?= n
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020022DPDK_MACHINE ?= default
Mohammed Hawarife909a62020-11-20 18:37:14 +010023DPDK_MLX_IBV_LINK ?= static
Damjan Marion561f2732018-09-21 12:27:45 +020024
Dastin Wilski2f132ef2022-03-30 14:19:00 +020025dpdk_version ?= 22.03
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020026dpdk_base_url ?= http://fast.dpdk.org/rel
27dpdk_tarball := dpdk-$(dpdk_version).tar.xz
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
Fan Zhang8990f092021-08-12 17:23:01 +010030dpdk_tarball_md5sum_21.08 := de33433a1806280996a0ecbe66e3642f
Fan Zhang9303b102021-05-27 13:24:52 +010031dpdk_tarball_md5sum_21.05 := a78bba290b11d9717d1272cc6bfaf7c3
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020032dpdk_tarball_md5sum := $(dpdk_tarball_md5sum_$(dpdk_version))
33dpdk_url := $(dpdk_base_url)/$(dpdk_tarball)
34dpdk_tarball_strip_dirs := 1
Mohammed Hawarife909a62020-11-20 18:37:14 +010035dpdk_depends := rdma-core $(if $(ARCH_X86_64), ipsec-mb)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020036# Debug or release
37
38DPDK_BUILD_TYPE:=release
39ifeq ($(DPDK_DEBUG), y)
40DPDK_BUILD_TYPE:=debug
Damjan Marion561f2732018-09-21 12:27:45 +020041endif
42
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020043DPDK_DRIVERS_DISABLED := baseband/\*, \
44 bus/dpaa, \
45 bus/ifpga, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040046 common/cnxk, \
Fan Zhang1152e602020-09-25 22:36:04 +010047 compress/isal, \
48 compress/octeontx, \
49 compress/zlib, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020050 crypto/ccp, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040051 crypto/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020052 crypto/dpaa_sec, \
53 crypto/openssl, \
PiotrX Kleski9235d432020-10-12 15:33:11 +020054 crypto/aesni_mb, \
55 crypto/aesni_gcm, \
56 crypto/kasumi, \
57 crypto/snow3g, \
58 crypto/zuc, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020059 event/\*, \
60 mempool/dpaa, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040061 mempool/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020062 net/af_packet, \
63 net/bnx2x, \
64 net/bonding, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040065 net/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020066 net/ipn3ke, \
67 net/liquidio, \
68 net/pcap, \
69 net/pfe, \
70 net/sfc, \
71 net/softnic, \
72 net/thunderx, \
73 raw/ifpga, \
Fan Zhang9303b102021-05-27 13:24:52 +010074 net/af_xdp
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020075
76DPDK_LIBS_DISABLED := acl, \
77 bbdev, \
78 bitratestats, \
79 bpf, \
80 cfgfile, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040081 cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020082 distributor, \
83 efd, \
84 fib, \
85 flow_classify, \
86 graph, \
87 gro, \
88 gso, \
89 jobstats, \
90 kni, \
91 latencystats, \
92 lpm, \
93 member, \
94 node, \
95 pipeline, \
96 port, \
97 power, \
98 rawdev, \
99 rib, \
100 table
101
Mohammed Hawarife909a62020-11-20 18:37:14 +0100102DPDK_MLX_CONFIG_FLAG :=
103
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200104# Adjust disabled pmd and libs depending on user provided variables
105ifeq ($(DPDK_MLX4_PMD), n)
106 DPDK_DRIVERS_DISABLED += ,net/mlx4
Mohammed Hawarife909a62020-11-20 18:37:14 +0100107else
108 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200109endif
110ifeq ($(DPDK_MLX5_PMD), n)
111 DPDK_DRIVERS_DISABLED += ,net/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100112else
113 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200114endif
115ifeq ($(DPDK_MLX5_COMMON_PMD), n)
116 DPDK_DRIVERS_DISABLED += ,common/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100117else
118 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200119endif
120ifeq ($(DPDK_TAP_PMD), n)
121 DPDK_DRIVERS_DISABLED += ,net/tap
122endif
123ifeq ($(DPDK_FAILSAFE_PMD), n)
124 DPDK_DRIVERS_DISABLED += ,net/failsafe
Damjan Marion561f2732018-09-21 12:27:45 +0200125endif
126
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200127# Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
128DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
129DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
Damjan Marion561f2732018-09-21 12:27:45 +0200130
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200131HASH := \#
132# post-meson-setup snippet to alter rte_build_config.h
133define dpdk_config
134if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then \
135sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
136 $(dpdk_src_dir)/config/rte_config.h; \
137elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
138sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
139 $(dpdk_build_dir)/rte_build_config.h; \
140else \
141echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
142 >> $(dpdk_build_dir)/rte_build_config.h ; \
Damjan Marion561f2732018-09-21 12:27:45 +0200143fi
144endef
145
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200146define dpdk_config_def
147if [[ "$(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 ; \
152 fi; \
153elif [[ "$(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 ; \
156fi
157endef
158
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200159DPDK_MESON_ARGS = \
160 --default-library static \
161 --libdir lib \
162 --prefix $(dpdk_install_dir) \
163 -Dtests=false \
164 "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
165 "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
166 -Db_pie=true \
167 -Dmachine=$(DPDK_MACHINE) \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100168 --buildtype=$(DPDK_BUILD_TYPE) \
169 ${DPDK_MLX_CONFIG_FLAG}
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200170
171PIP_DOWNLOAD_DIR = $(CURDIR)/downloads/
Damjan Marion561f2732018-09-21 12:27:45 +0200172
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200173define 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 && \
Nick Brownae4ed322021-09-07 18:24:42 +0100179 (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 && \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100181 PKG_CONFIG_PATH=$(dpdk_install_dir)/lib/pkgconfig meson setup $(dpdk_src_dir) \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200182 $(dpdk_build_dir) \
183 $(DPDK_MESON_ARGS) \
184 | tee $(dpdk_config_log) && \
185 deactivate && \
186 echo "DPDK post meson configuration" && \
187 echo "Altering rte_build_config.h" && \
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200188 $(call dpdk_config,PKTMBUF_HEADROOM) && \
189 $(call dpdk_config_def,USE_LIBBSD)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200190endef
BenoƮt Gannefe750c22019-03-25 11:41:34 +0100191
Nick Brownae4ed322021-09-07 18:24:42 +0100192ifeq ("$(DPDK_VERBOSE)","1")
193DPDK_VERBOSE_BUILD = --verbose
194endif
195
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200196define dpdk_build_cmds
197 cd $(dpdk_build_dir) && \
198 source ../dpdk-meson-venv/bin/activate && \
Nick Brownae4ed322021-09-07 18:24:42 +0100199 meson compile $(DPDK_VERBOSE_BUILD) -C . | tee $(dpdk_build_log) && \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200200 deactivate
201endef
Damjan Marion561f2732018-09-21 12:27:45 +0200202
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200203define dpdk_install_cmds
204 cd $(dpdk_build_dir) && \
205 source ../dpdk-meson-venv/bin/activate && \
206 meson install && \
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.* && \
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200210 deactivate
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200211endef
Damjan Marion561f2732018-09-21 12:27:45 +0200212
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200213$(eval $(call package,dpdk))