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