From 57d5ce26e8bca43631f9e71607f0cfbb254906ac Mon Sep 17 00:00:00 2001 From: Heinrich Kuhn Date: Wed, 18 Aug 2021 16:38:53 +0200 Subject: Add support for building Prox with Meson DPDK has deprecated the use of the make system in versions 20.11 and beyond. Following the deprecation it is non-trivial to keep using make to build projects that depend on DPDK. A cleaner solution is to adopt Meson as a building framework. This commit adds support for Meson in Prox. The meson.build file mirrors the functionality that is available in the current Makefile. The make build system will exit if it detects that DPDK was built using meson (testing for the RTE_TARGET directory) Signed-off-by: Heinrich Kuhn Signed-off-by: Simon Horman Change-Id: I6ebffa2199993fd6eb46c2f31961fe7dc38e727c --- VNFs/DPPD-PROX/Makefile | 19 +++- VNFs/DPPD-PROX/README | 41 +++++++-- VNFs/DPPD-PROX/git_version.c.in | 1 + VNFs/DPPD-PROX/input_curses.c | 3 + VNFs/DPPD-PROX/meson.build | 190 +++++++++++++++++++++++++++++++++++++++ VNFs/DPPD-PROX/meson_options.txt | 9 ++ 6 files changed, 257 insertions(+), 6 deletions(-) create mode 100644 VNFs/DPPD-PROX/git_version.c.in create mode 100644 VNFs/DPPD-PROX/meson.build create mode 100644 VNFs/DPPD-PROX/meson_options.txt (limited to 'VNFs') diff --git a/VNFs/DPPD-PROX/Makefile b/VNFs/DPPD-PROX/Makefile index 60cea67f..a659c03f 100644 --- a/VNFs/DPPD-PROX/Makefile +++ b/VNFs/DPPD-PROX/Makefile @@ -15,12 +15,28 @@ ## ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") +define err_msg + +Please define RTE_SDK environment variable. +If DPDK was built with Meson, please use meson to build Prox too. +*** +endef +$(error $(err_msg)) endif # Default target, can be overriden by command line or environment RTE_TARGET ?= x86_64-native-linuxapp-gcc +ifeq ($(wildcard $(RTE_SDK)/$(RTE_TARGET)/.),) +define err_msg + +Could not find build target: $(RTE_TARGET) +Perhaps DPDK was built using meson? +*** +endef +$(error $(err_msg)) +endif + rte_version_h := $(RTE_SDK)/$(RTE_TARGET)/include/rte_version.h rte_config_h := $(RTE_SDK)/$(RTE_TARGET)/include/rte_config.h rte_ver_part = $(shell sed -n -e 's/^\#define\s*$1\s*\(.*\)$$/\1/p' $(rte_version_h)) @@ -56,6 +72,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # binary name APP = prox CFLAGS += -DPROGRAM_NAME=\"$(APP)\" +CFLAGS += -DCOMPILED_WITH_MAKE CFLAGS += -O2 -g CFLAGS += -fno-stack-protector -Wno-deprecated-declarations diff --git a/VNFs/DPPD-PROX/README b/VNFs/DPPD-PROX/README index 2380ab61..344214f0 100644 --- a/VNFs/DPPD-PROX/README +++ b/VNFs/DPPD-PROX/README @@ -26,8 +26,39 @@ Compiling and running this application -------------------------------------- This application supports DPDK 16.04, 16.11, 16.11.1, 17.02, 17.05, 17.08, 17.11, 18.02, 18.05, 18.08, 18.11, 19.02, 19.05, 19.08, 19.11, 20.02 and -20.05. - +20.05 20.11 + +Meson compilation +----------------- +Support for 'make' has been deprecated in DPDK from v20.11 onward. + +Example: DPDK 20.11 installation with meson +------------------------------------------- +git clone http://dpdk.org/git/dpdk-stable +git checkout 20.11 +meson build +cd build +ninja +ninja install +ldconfig + +PROX meson compilation (From the root of this repo) +-------------------------------------------------- +Depending on the distribution in use the DPDK libraries will be installed in +different locations. The 'PKG_CONFIG_PATH' environment variable is used to +point to the correct location. + +For RHEL/CentOS systems: +export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig +meson build +cd build +ninja + +Additional options can be passed to the meson build system. See the +'meson_options.txt' file for possible options + +Legacy Make compilation +----------------------- The following commands assume that the following variables have been set: export RTE_SDK=/path/to/dpdk @@ -40,14 +71,14 @@ the multi-buffer library which can be downloaded from . See doc/guides/cryptodevs/aesni_mb.rst within dpdk for more details -Example: DPDK 17.05 installation --------------------------------- +Example: DPDK 17.05 installation with make +------------------------------------------ git clone http://dpdk.org/git/dpdk cd dpdk git checkout v17.05 make install T=$RTE_TARGET -PROX compilation +PROX make compilation ---------------- The Makefile with this application expects RTE_SDK to point to the root directory of DPDK (e.g. export RTE_SDK=/root/dpdk). If RTE_TARGET diff --git a/VNFs/DPPD-PROX/git_version.c.in b/VNFs/DPPD-PROX/git_version.c.in new file mode 100644 index 00000000..d151b589 --- /dev/null +++ b/VNFs/DPPD-PROX/git_version.c.in @@ -0,0 +1 @@ +const char *git_version="@GIT_VERSION@"; diff --git a/VNFs/DPPD-PROX/input_curses.c b/VNFs/DPPD-PROX/input_curses.c index 4ea2e4a8..f549f859 100644 --- a/VNFs/DPPD-PROX/input_curses.c +++ b/VNFs/DPPD-PROX/input_curses.c @@ -27,7 +27,10 @@ #include "cmd_parser.h" #include "input_curses.h" #include "histedit.h" + +#ifdef COMPILED_WITH_MAKE #include "libedit_autoconf.h" +#endif static EditLine *el; static History *hist; diff --git a/VNFs/DPPD-PROX/meson.build b/VNFs/DPPD-PROX/meson.build new file mode 100644 index 00000000..41cf6553 --- /dev/null +++ b/VNFs/DPPD-PROX/meson.build @@ -0,0 +1,190 @@ +## +## Copyright (c) 2021 Heinrich Kuhn +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +project('dppd-prox', 'C', + version: + run_command(['git', 'describe', + '--abbrev=8', '--dirty', '--always']).stdout().strip(), + license: 'Apache', + default_options: ['buildtype=release', 'c_std=gnu99'], + meson_version: '>= 0.47' +) + +cc = meson.get_compiler('c') + +# Configure options for prox +if get_option('bng_qinq').enabled() + add_project_arguments('-DUSE_QINQ', language: 'c') +endif + +if get_option('mpls_routing').enabled() + add_project_arguments('-DMPLS_ROUTING', language: 'c') +endif + +if get_option('prox_stats').enabled() + add_project_arguments('-DPROX_STATS', language: 'c') +endif + +if get_option('hw_direct_stats').enabled() + add_project_arguments('-DPROX_HW_DIRECT_STATS', language: 'c') +endif + +if get_option('dbg') + add_project_arguments('-ggdb', language: 'c') +endif + +if get_option('log') + add_project_arguments('-DPROX_MAX_LOG_LVL=2', language: 'c') +endif + +if get_option('gen_decap_ipv6_to_ipv4_cksum').enabled() + add_project_arguments('-DGEN_DECAP_IPV6_TO_IPV4_CKSUM', language: 'c') +endif + +if get_option('crc') == 'soft' + add_project_arguments('-DSOFT_CRC', language: 'c') +endif + +cflags = [ + '-DPROGRAM_NAME="prox"', + '-fno-stack-protector', + '-DPROX_PREFETCH_OFFSET=2', + '-DLATENCY_PER_PACKET', + '-DLATENCY_HISTOGRAM', + '-DGRE_TP', + '-D_GNU_SOURCE'] # for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + +# Add configured cflags to arguments +foreach arg: cflags + add_project_arguments(arg, language: 'c') +endforeach + +# enable warning flags if they are supported by the compiler +warning_flags = [ + '-Wno-unused', + '-Wno-unused-parameter', + '-Wno-unused-result', + '-Wno-deprecated-declarations'] + +foreach arg: warning_flags + if cc.has_argument(arg) + add_project_arguments(arg, language: 'c') + endif +endforeach + +# Attempt to find a suitable lua and add to deps +lua_versions = ['lua', 'lua5.2', 'lua5.3'] +foreach i:lua_versions + lua_dep = dependency(i, required: false) + if not lua_dep.found() + lua_dep = cc.find_library(i, required: false) + endif + if lua_dep.found() + break + endif +endforeach +if not lua_dep.found() + error('Suitable lua version not found') +endif + +# All other dependencies +dpdk_dep = dependency('libdpdk', required: true) +tinfo_dep = dependency('tinfo', required: false) +threads_dep = dependency('threads', required: true) +pcap_dep = dependency('pcap', required: true) +ncurses_dep = dependency('ncurses', required: true) +ncursesw_dep = dependency('ncursesw', required: true) +libedit_dep = dependency('libedit', required: true) +math_dep = cc.find_library('m', required : false) + +deps = [dpdk_dep, + tinfo_dep, + threads_dep, + pcap_dep, + ncurses_dep, + ncursesw_dep, + libedit_dep, + math_dep, + lua_dep] + +# Grab the DPDK version here "manually" as it is not available in the dpdk_dep +# object +dpdk_version = run_command('pkg-config', '--modversion', 'libdpdk').stdout() + +# Explicitly add these to the dependency list +deps += [cc.find_library('rte_bus_vdev', required: true)] + +if dpdk_version.version_compare('<20.11.0') +deps += [cc.find_library('rte_pmd_ring', required: true)] +else +deps += [cc.find_library('rte_net_ring', required: true)] +endif + +sources = files( + 'task_init.c', 'handle_aggregator.c', 'handle_nop.c', 'handle_irq.c', + 'handle_arp.c', 'handle_impair.c', 'handle_lat.c', 'handle_qos.c', + 'handle_qinq_decap4.c', 'handle_routing.c', 'handle_untag.c', + 'handle_mplstag.c', 'handle_qinq_decap6.c', 'rw_reg.c', + 'handle_lb_qinq.c', 'handle_lb_pos.c', 'handle_lb_net.c', + 'handle_qinq_encap4.c', 'handle_qinq_encap6.c', 'handle_classify.c', + 'handle_l2fwd.c', 'handle_swap.c', 'handle_police.c', 'handle_acl.c', + 'handle_gen.c', 'handle_master.c', 'packet_utils.c', 'handle_mirror.c', + 'handle_genl4.c', 'handle_ipv6_tunnel.c', 'handle_read.c', + 'handle_cgnat.c', 'handle_nat.c', 'handle_dump.c', 'handle_tsc.c', + 'handle_fm.c', 'handle_lb_5tuple.c', 'handle_blockudp.c', 'toeplitz.c', + 'thread_nop.c', 'thread_generic.c', 'prox_args.c', 'prox_cfg.c', + 'prox_cksum.c', 'prox_port_cfg.c', 'cfgfile.c', 'clock.c', + 'commands.c', 'cqm.c', 'msr.c', 'defaults.c', 'display.c', + 'display_latency.c', 'display_latency_distr.c', 'display_mempools.c', + 'display_ports.c', 'display_rings.c', 'display_priority.c', + 'display_pkt_len.c', 'display_l4gen.c', 'display_tasks.c', + 'display_irq.c', 'log.c', 'hash_utils.c', 'main.c', 'parse_utils.c', + 'file_utils.c', 'run.c', 'input_conn.c', 'input_curses.c', 'rx_pkt.c', + 'lconf.c', 'tx_pkt.c', 'expire_cpe.c', 'ip_subnet.c', 'stats_port.c', + 'stats_mempool.c', 'stats_ring.c', 'stats_l4gen.c', 'stats_latency.c', + 'stats_global.c', 'stats_core.c', 'stats_task.c', 'stats_prio.c', + 'stats_irq.c', 'cmd_parser.c', 'input.c', 'prox_shared.c', + 'prox_lua_types.c', 'genl4_bundle.c', 'heap.c', 'genl4_stream_tcp.c', + 'genl4_stream_udp.c', 'cdf.c', 'stats.c', 'stats_cons_log.c', + 'stats_cons_cli.c', 'stats_parser.c', 'hash_set.c', 'prox_lua.c', + 'prox_malloc.c', 'prox_ipv6.c', 'prox_compat.c', 'handle_nsh.c') + +# Include a couple of source files depending on DPDK support +if cc.find_library('rte_pmd_aesni', required: false).found() + sources += files('handle_esp.c') +else + warning('Building w/o IPSEC support') +endif + +if cc.find_library('rte_pipeline', required: false).found() + sources += files('handle_pf_acl.c', 'thread_pipeline.c') +endif + +# Generate the git_version.c file and add to sources +git_version = configuration_data() +git_version.set('GIT_VERSION', '@0@'.format(meson.project_version())) +git_version_c = configure_file(input: 'git_version.c.in', + output: 'git_version.c', + configuration: git_version) + +git_version_file = join_paths(meson.current_build_dir(), 'git_version.c') +sources += files(git_version_file) + +executable('prox', + sources, + c_args: cflags, + dependencies: deps, + install: true) diff --git a/VNFs/DPPD-PROX/meson_options.txt b/VNFs/DPPD-PROX/meson_options.txt new file mode 100644 index 00000000..29f40559 --- /dev/null +++ b/VNFs/DPPD-PROX/meson_options.txt @@ -0,0 +1,9 @@ +#Keep the options sorted alphabetically +option('crc', type: 'string', value: 'soft') +option('bng_qinq', type: 'feature', value: 'enabled') +option('dbg', type: 'boolean', value: false) +option('gen_decap_ipv6_to_ipv4_cksum', type: 'feature', value: 'enabled') +option('hw_direct_stats', type: 'feature', value: 'enabled') +option('log', type: 'boolean', value: true) +option('mpls_routing', type: 'feature', value: 'enabled') +option('prox_stats', type: 'feature', value: 'enabled') -- cgit 1.2.3-korg