blob: b963c363738022ad458b87f0f80ca86430a2840f [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
Fan Zhang3c285b52022-08-02 10:17:08 +000025dpdk_version ?= 22.07
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020026dpdk_base_url ?= http://fast.dpdk.org/rel
27dpdk_tarball := dpdk-$(dpdk_version).tar.xz
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
Fan Zhang8990f092021-08-12 17:23:01 +010031dpdk_tarball_md5sum_21.08 := de33433a1806280996a0ecbe66e3642f
Fan Zhang9303b102021-05-27 13:24:52 +010032dpdk_tarball_md5sum_21.05 := a78bba290b11d9717d1272cc6bfaf7c3
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020033dpdk_tarball_md5sum := $(dpdk_tarball_md5sum_$(dpdk_version))
34dpdk_url := $(dpdk_base_url)/$(dpdk_tarball)
35dpdk_tarball_strip_dirs := 1
Mohammed Hawarife909a62020-11-20 18:37:14 +010036dpdk_depends := rdma-core $(if $(ARCH_X86_64), ipsec-mb)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020037# Debug or release
38
39DPDK_BUILD_TYPE:=release
40ifeq ($(DPDK_DEBUG), y)
41DPDK_BUILD_TYPE:=debug
Damjan Marion561f2732018-09-21 12:27:45 +020042endif
43
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020044DPDK_DRIVERS_DISABLED := baseband/\*, \
45 bus/dpaa, \
46 bus/ifpga, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040047 common/cnxk, \
Fan Zhang1152e602020-09-25 22:36:04 +010048 compress/isal, \
49 compress/octeontx, \
50 compress/zlib, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020051 crypto/ccp, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040052 crypto/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020053 crypto/dpaa_sec, \
54 crypto/openssl, \
PiotrX Kleski9235d432020-10-12 15:33:11 +020055 crypto/aesni_mb, \
56 crypto/aesni_gcm, \
57 crypto/kasumi, \
58 crypto/snow3g, \
59 crypto/zuc, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020060 event/\*, \
61 mempool/dpaa, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040062 mempool/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020063 net/af_packet, \
64 net/bnx2x, \
65 net/bonding, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040066 net/cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020067 net/ipn3ke, \
68 net/liquidio, \
69 net/pcap, \
70 net/pfe, \
71 net/sfc, \
72 net/softnic, \
73 net/thunderx, \
74 raw/ifpga, \
Fan Zhang9303b102021-05-27 13:24:52 +010075 net/af_xdp
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020076
77DPDK_LIBS_DISABLED := acl, \
78 bbdev, \
79 bitratestats, \
80 bpf, \
81 cfgfile, \
Dave Wallacef5b8e8d2022-08-11 15:29:54 -040082 cnxk, \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +020083 distributor, \
84 efd, \
85 fib, \
86 flow_classify, \
87 graph, \
88 gro, \
89 gso, \
90 jobstats, \
91 kni, \
92 latencystats, \
93 lpm, \
94 member, \
95 node, \
96 pipeline, \
97 port, \
98 power, \
99 rawdev, \
100 rib, \
101 table
102
Mohammed Hawarife909a62020-11-20 18:37:14 +0100103DPDK_MLX_CONFIG_FLAG :=
104
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200105# Adjust disabled pmd and libs depending on user provided variables
106ifeq ($(DPDK_MLX4_PMD), n)
107 DPDK_DRIVERS_DISABLED += ,net/mlx4
Mohammed Hawarife909a62020-11-20 18:37:14 +0100108else
109 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200110endif
111ifeq ($(DPDK_MLX5_PMD), n)
112 DPDK_DRIVERS_DISABLED += ,net/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100113else
114 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200115endif
116ifeq ($(DPDK_MLX5_COMMON_PMD), n)
117 DPDK_DRIVERS_DISABLED += ,common/mlx5
Mohammed Hawarife909a62020-11-20 18:37:14 +0100118else
119 DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200120endif
121ifeq ($(DPDK_TAP_PMD), n)
122 DPDK_DRIVERS_DISABLED += ,net/tap
123endif
124ifeq ($(DPDK_FAILSAFE_PMD), n)
125 DPDK_DRIVERS_DISABLED += ,net/failsafe
Damjan Marion561f2732018-09-21 12:27:45 +0200126endif
127
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200128# Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
129DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
130DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
Damjan Marion561f2732018-09-21 12:27:45 +0200131
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200132HASH := \#
133# post-meson-setup snippet to alter rte_build_config.h
134define dpdk_config
135if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then \
136sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
137 $(dpdk_src_dir)/config/rte_config.h; \
138elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
139sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
140 $(dpdk_build_dir)/rte_build_config.h; \
141else \
142echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
143 >> $(dpdk_build_dir)/rte_build_config.h ; \
Damjan Marion561f2732018-09-21 12:27:45 +0200144fi
145endef
146
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200147define dpdk_config_def
148if [[ "$(DPDK_$(1))" == "y" ]]; then \
149 if ! grep -q "RTE_$(1)" $(dpdk_build_dir)/rte_build_config.h \
150 $(dpdk_src_dir)/config/rte_config.h ; then \
151 echo '$(HASH)define RTE_$(1) 1' \
152 >> $(dpdk_build_dir)/rte_build_config.h ; \
153 fi; \
154elif [[ "$(DPDK_$(1))" == "n" ]]; then \
155 sed -i '/$(HASH)define RTE_$(1) .*/d' $(dpdk_build_dir)/rte_build_config.h \
156 $(dpdk_src_dir)/config/rte_config.h ; \
157fi
158endef
159
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200160DPDK_MESON_ARGS = \
161 --default-library static \
162 --libdir lib \
163 --prefix $(dpdk_install_dir) \
164 -Dtests=false \
165 "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
166 "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
167 -Db_pie=true \
168 -Dmachine=$(DPDK_MACHINE) \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100169 --buildtype=$(DPDK_BUILD_TYPE) \
170 ${DPDK_MLX_CONFIG_FLAG}
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200171
172PIP_DOWNLOAD_DIR = $(CURDIR)/downloads/
Damjan Marion561f2732018-09-21 12:27:45 +0200173
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200174define dpdk_config_cmds
175 cd $(dpdk_build_dir) && \
176 rm -rf ../dpdk-meson-venv && \
177 mkdir -p ../dpdk-meson-venv && \
178 python3 -m venv ../dpdk-meson-venv && \
179 source ../dpdk-meson-venv/bin/activate && \
Nick Brownae4ed322021-09-07 18:24:42 +0100180 (if ! ls $(PIP_DOWNLOAD_DIR)meson* ; then pip3 download -d $(PIP_DOWNLOAD_DIR) -f $(DL_CACHE_DIR) meson==0.55 setuptools wheel pyelftools; fi) && \
181 pip3 install --no-index --find-links=$(PIP_DOWNLOAD_DIR) meson==0.55 pyelftools && \
Mohammed Hawarife909a62020-11-20 18:37:14 +0100182 PKG_CONFIG_PATH=$(dpdk_install_dir)/lib/pkgconfig meson setup $(dpdk_src_dir) \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200183 $(dpdk_build_dir) \
184 $(DPDK_MESON_ARGS) \
185 | tee $(dpdk_config_log) && \
186 deactivate && \
187 echo "DPDK post meson configuration" && \
188 echo "Altering rte_build_config.h" && \
Mohammed Hawari1f799bc2020-09-18 21:47:04 +0200189 $(call dpdk_config,PKTMBUF_HEADROOM) && \
190 $(call dpdk_config_def,USE_LIBBSD)
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200191endef
BenoƮt Gannefe750c22019-03-25 11:41:34 +0100192
Nick Brownae4ed322021-09-07 18:24:42 +0100193ifeq ("$(DPDK_VERBOSE)","1")
194DPDK_VERBOSE_BUILD = --verbose
195endif
196
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200197define dpdk_build_cmds
198 cd $(dpdk_build_dir) && \
199 source ../dpdk-meson-venv/bin/activate && \
Nick Brownae4ed322021-09-07 18:24:42 +0100200 meson compile $(DPDK_VERBOSE_BUILD) -C . | tee $(dpdk_build_log) && \
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200201 deactivate
202endef
Damjan Marion561f2732018-09-21 12:27:45 +0200203
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200204define dpdk_install_cmds
205 cd $(dpdk_build_dir) && \
206 source ../dpdk-meson-venv/bin/activate && \
207 meson install && \
208 cd $(dpdk_install_dir)/lib && \
209 echo "GROUP ( $$(ls librte*.a ) )" > libdpdk.a && \
210 rm -rf librte*.so librte*.so.* dpdk/*/librte*.so dpdk/*/librte*.so.* && \
Mohammed Hawaria6d5f242020-10-22 14:14:04 +0200211 deactivate
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200212endef
Damjan Marion561f2732018-09-21 12:27:45 +0200213
Mohammed Hawari4c4633c2020-09-15 14:05:11 +0200214$(eval $(call package,dpdk))