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