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