dpdk: bump to DPDK 23.11
[vpp.git] / build / external / packages / dpdk.mk
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:
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
14 DPDK_PKTMBUF_HEADROOM        ?= 128
15 DPDK_USE_LIBBSD              ?= n
16 DPDK_DEBUG                   ?= n
17 DPDK_TAP_PMD                 ?= n
18 DPDK_FAILSAFE_PMD            ?= n
19 DPDK_MACHINE                 ?= default
20 DPDK_MLX_IBV_LINK            ?= static
21
22 dpdk_version                 ?= 23.11
23 dpdk_base_url                ?= http://fast.dpdk.org/rel
24 dpdk_tarball                 := dpdk-$(dpdk_version).tar.xz
25 dpdk_tarball_md5sum_23.11    := 896c09f5b45b452bd77287994650b916
26 dpdk_tarball_md5sum_23.07    := 2b6d57f077585cb15b885482362fd47f
27 dpdk_tarball_md5sum_23.03    := 3cf8ebbcd412d5726db230f2eeb90cc9
28 dpdk_tarball_md5sum_22.11.1  := 0594708fe42ce186a55b0235c6e20cfe
29 dpdk_tarball_md5sum_22.07    := fb73b58b80b1349cd05fe9cf6984afd4
30 dpdk_tarball_md5sum_22.03    := a07ca8839f98062f46e1cc359735cce8
31 dpdk_tarball_md5sum_21.11    := 58660bbbe9e95abce86e47692b196555
32 dpdk_tarball_md5sum          := $(dpdk_tarball_md5sum_$(dpdk_version))
33 dpdk_url                     := $(dpdk_base_url)/$(dpdk_tarball)
34 dpdk_tarball_strip_dirs      := 1
35 dpdk_depends                 := rdma-core $(if $(ARCH_X86_64), ipsec-mb)
36
37 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)
38 DPDK_MLX4_PMD                ?= $(DPDK_MLX_DEFAULT)
39 DPDK_MLX5_PMD                ?= $(DPDK_MLX_DEFAULT)
40 DPDK_MLX5_COMMON_PMD         ?= $(DPDK_MLX_DEFAULT)
41 # Debug or release
42
43 DPDK_BUILD_TYPE:=release
44 ifeq ($(DPDK_DEBUG), y)
45 DPDK_BUILD_TYPE:=debug
46 endif
47
48 DPDK_DRIVERS_DISABLED := baseband/\*,   \
49         bus/dpaa,                                                       \
50         bus/ifpga,                                                      \
51         common/cnxk,                                            \
52         compress/isal,                                          \
53         compress/octeontx,                                      \
54         compress/zlib,                                          \
55         crypto/ccp,                                                     \
56         crypto/cnxk,                                            \
57         crypto/dpaa_sec,                                        \
58         crypto/openssl,                                         \
59         crypto/aesni_mb,                                                \
60         crypto/aesni_gcm,                                               \
61         crypto/kasumi,                                          \
62         crypto/snow3g,                                          \
63         crypto/zuc,                                             \
64         event/\*,                                                       \
65         mempool/dpaa,                                           \
66         mempool/cnxk,                                           \
67         net/af_packet,                                          \
68         net/bnx2x,                                                      \
69         net/bonding,                                            \
70         net/cnxk,                                                       \
71         net/ipn3ke,                                                     \
72         net/liquidio,                                           \
73         net/pcap,                                                       \
74         net/pfe,                                                        \
75         net/sfc,                                                        \
76         net/softnic,                                            \
77         net/thunderx,                                           \
78         raw/ifpga,                                                      \
79         net/af_xdp
80
81 DPDK_LIBS_DISABLED := acl,                              \
82         bbdev,                                                          \
83         bitratestats,                                           \
84         bpf,                                                            \
85         cfgfile,                                                        \
86         cnxk,                                                   \
87         distributor,                                            \
88         efd,                                                            \
89         fib,                                                            \
90         flow_classify,                                          \
91         graph,                                                          \
92         gro,                                                            \
93         gso,                                                            \
94         jobstats,                                                       \
95         kni,                                                            \
96         latencystats,                                           \
97         lpm,                                                            \
98         member,                                                         \
99         node,                                                           \
100         pipeline,                                                       \
101         port,                                                           \
102         power,                                                          \
103         rawdev,                                                         \
104         rib,                                                            \
105         table
106
107 DPDK_MLX_CONFIG_FLAG :=
108
109 # Adjust disabled pmd and libs depending on user provided variables
110 ifeq ($(DPDK_MLX4_PMD), n)
111         DPDK_DRIVERS_DISABLED += ,net/mlx4
112 else
113         DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
114 endif
115 ifeq ($(DPDK_MLX5_PMD), n)
116         DPDK_DRIVERS_DISABLED += ,net/mlx5
117 else
118         DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
119 endif
120 ifeq ($(DPDK_MLX5_COMMON_PMD), n)
121         DPDK_DRIVERS_DISABLED += ,common/mlx5
122 else
123         DPDK_MLX_CONFIG_FLAG := -Dibverbs_link=${DPDK_MLX_IBV_LINK}
124 endif
125 ifeq ($(DPDK_TAP_PMD), n)
126         DPDK_DRIVERS_DISABLED += ,net/tap
127 endif
128 ifeq ($(DPDK_FAILSAFE_PMD), n)
129         DPDK_DRIVERS_DISABLED += ,net/failsafe
130 endif
131
132 # Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
133 DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
134 DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
135
136 HASH := \#
137 # post-meson-setup snippet to alter rte_build_config.h
138 define dpdk_config
139 if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then  \
140 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
141         $(dpdk_src_dir)/config/rte_config.h; \
142 elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
143 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
144         $(dpdk_build_dir)/rte_build_config.h; \
145 else \
146 echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
147         >> $(dpdk_build_dir)/rte_build_config.h ; \
148 fi
149 endef
150
151 define dpdk_config_def
152 if [[ "$(DPDK_$(1))" == "y" ]]; then \
153     if ! grep -q "RTE_$(1)" $(dpdk_build_dir)/rte_build_config.h \
154       $(dpdk_src_dir)/config/rte_config.h ; then \
155         echo '$(HASH)define RTE_$(1) 1' \
156           >> $(dpdk_build_dir)/rte_build_config.h ; \
157     fi; \
158 elif [[ "$(DPDK_$(1))" == "n" ]]; then \
159     sed -i '/$(HASH)define RTE_$(1) .*/d' $(dpdk_build_dir)/rte_build_config.h \
160       $(dpdk_src_dir)/config/rte_config.h ; \
161 fi
162 endef
163
164 DPDK_MESON_ARGS = \
165         --default-library static \
166         --libdir lib \
167         --prefix $(dpdk_install_dir) \
168         -Dtests=false \
169         -Denable_driver_sdk=true \
170         "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
171         "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
172         -Db_pie=true \
173         -Dmachine=$(DPDK_MACHINE) \
174         --buildtype=$(DPDK_BUILD_TYPE) \
175         ${DPDK_MLX_CONFIG_FLAG}
176
177 PIP_DOWNLOAD_DIR = $(CURDIR)/downloads/
178
179 define dpdk_config_cmds
180         cd $(dpdk_build_dir) && \
181         echo "DPDK_MLX_DEFAULT=$(DPDK_MLX_DEFAULT)" > ../../../dpdk_mlx_default.sh && \
182         rm -rf ../dpdk-meson-venv && \
183         mkdir -p ../dpdk-meson-venv && \
184         python3 -m venv ../dpdk-meson-venv && \
185         source ../dpdk-meson-venv/bin/activate && \
186         (if ! ls $(PIP_DOWNLOAD_DIR)meson* ; then pip3 download -d $(PIP_DOWNLOAD_DIR) -f $(DL_CACHE_DIR) meson==0.55.3 setuptools wheel pyelftools; fi) && \
187         pip3 install --no-index --find-links=$(PIP_DOWNLOAD_DIR) meson==0.55.3 pyelftools && \
188         PKG_CONFIG_PATH=$(dpdk_install_dir)/lib/pkgconfig meson setup $(dpdk_src_dir) \
189                 $(dpdk_build_dir) \
190                 $(DPDK_MESON_ARGS) \
191                         | tee $(dpdk_config_log) && \
192         deactivate && \
193         echo "DPDK post meson configuration" && \
194         echo "Altering rte_build_config.h" && \
195         $(call dpdk_config,PKTMBUF_HEADROOM) && \
196         $(call dpdk_config_def,USE_LIBBSD)
197 endef
198
199 ifeq ("$(DPDK_VERBOSE)","1")
200 DPDK_VERBOSE_BUILD = --verbose
201 endif
202
203 define dpdk_build_cmds
204         cd $(dpdk_build_dir) && \
205         source ../dpdk-meson-venv/bin/activate && \
206         meson compile $(DPDK_VERBOSE_BUILD) -C . | tee $(dpdk_build_log) && \
207         deactivate
208 endef
209
210 define dpdk_install_cmds
211         cd $(dpdk_build_dir) && \
212         source ../dpdk-meson-venv/bin/activate && \
213         meson install && \
214         cd $(dpdk_install_dir)/lib && \
215         echo "GROUP ( $$(ls librte*.a ) )" > libdpdk.a && \
216         rm -rf librte*.so librte*.so.* dpdk/*/librte*.so dpdk/*/librte*.so.* && \
217         deactivate
218 endef
219
220 $(eval $(call package,dpdk))