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