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