diff options
author | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2021-09-30 10:05:39 +0000 |
---|---|---|
committer | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2021-11-10 11:55:12 +0000 |
commit | b792c1f27d58040f3a815da18183d329bd6bd84b (patch) | |
tree | def302a01c2136211651fb90994806ae1ff0a32a | |
parent | f71107b4dd6a4b8b1cd28d7339c924f1b013cfa4 (diff) |
tldk: swtich to use DPDK 20.11 LTS
As in DPDK 20.11 'make' is not supported any more,
switch to use pkg-conf approach.
Note that RTE_SDK now should point to your DPDK package installation path.
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Change-Id: I4a3c394758e183a3ddcdb45a0562a81583daaab6
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
-rw-r--r-- | Makefile | 30 | ||||
-rw-r--r-- | dpdk/Makefile | 169 | ||||
-rw-r--r-- | examples/Makefile | 2 | ||||
-rw-r--r-- | examples/l4fwd/Makefile | 33 | ||||
-rw-r--r-- | examples/l4fwd/lcore.h | 2 | ||||
-rw-r--r-- | examples/l4fwd/main.c | 4 | ||||
-rw-r--r-- | lib/Makefile | 9 | ||||
-rw-r--r-- | lib/libtle_dring/Makefile | 18 | ||||
-rw-r--r-- | lib/libtle_l4p/Makefile | 22 | ||||
-rw-r--r-- | lib/libtle_l4p/ctx.c | 2 | ||||
-rw-r--r-- | lib/libtle_l4p/syncookie.h | 2 | ||||
-rw-r--r-- | lib/libtle_memtank/Makefile | 18 | ||||
-rw-r--r-- | lib/libtle_misc/Makefile | 18 | ||||
-rw-r--r-- | lib/libtle_misc/tle_dpdk_wrapper.h | 7 | ||||
-rw-r--r-- | lib/libtle_timer/Makefile | 18 | ||||
-rw-r--r-- | mk/tle.app.mk | 55 | ||||
-rw-r--r-- | mk/tle.cpp-obj.mk | 97 | ||||
-rw-r--r-- | mk/tle.cpp-pre.mk | 91 | ||||
-rw-r--r-- | mk/tle.cpp-vars.mk | 45 | ||||
-rw-r--r-- | mk/tle.lib.mk | 53 | ||||
-rw-r--r-- | mk/tle.subdir.mk | 5 | ||||
-rw-r--r-- | mk/tle.var.mk | 58 | ||||
-rw-r--r-- | test/Makefile | 2 | ||||
-rw-r--r-- | test/dring/Makefile | 26 | ||||
-rw-r--r-- | test/dring/test_dring.c | 4 | ||||
-rw-r--r-- | test/gtest/Makefile | 115 | ||||
-rw-r--r-- | test/gtest/test_tle_dring.h | 4 | ||||
-rw-r--r-- | test/memtank/Makefile | 26 | ||||
-rw-r--r-- | test/memtank/test_memtank.c | 11 | ||||
-rw-r--r-- | test/timer/Makefile | 26 |
30 files changed, 289 insertions, 683 deletions
@@ -14,13 +14,15 @@ TLDK_ROOT := $(CURDIR) export TLDK_ROOT -LOCAL_RTE_SDK=$(TLDK_ROOT)/dpdk/_build/dpdk +RTE_TARGET ?= x86_64-native-linuxapp-gcc + +LOCAL_RTE_SDK=$(TLDK_ROOT)/dpdk/$(RTE_TARGET) ifeq ($(RTE_SDK),) export RTE_SDK=$(LOCAL_RTE_SDK) endif -RTE_TARGET ?= x86_64-native-linuxapp-gcc +RTE_PKG_CONF=$(RTE_SDK)/lib/x86_64-linux-gnu/pkgconfig DIRS-y += lib DIRS-y += examples @@ -33,24 +35,34 @@ O ?= $(TLDK_ROOT)/${RTE_TARGET} BASE_OUTPUT ?= $(abspath $(O)) .PHONY: all -all: $(DIRS-y) +all: $(BASE_OUTPUT) $(DIRS-y) .PHONY: clean -clean: $(DIRS-y) +clean: $(DIRS-y) $(RTE_PKG_CONF) + $(Q)rm -rf $(BASE_OUTPUT) +ifeq ($(RTE_SDK),$(LOCAL_RTE_SDK)) + $(Q)make $(@) -C $(TLDK_ROOT)/dpdk O=$(RTE_SDK) +endif + +examples test: lib .PHONY: $(DIRS-y) -$(DIRS-y): $(RTE_SDK)/mk/rte.vars.mk +$(DIRS-y): $(RTE_PKG_CONF) @echo "== $@" $(Q)$(MAKE) -C $(@) \ M=$(CURDIR)/$(@)/Makefile \ O=$(BASE_OUTPUT) \ - BASE_OUTPUT=$(BASE_OUTPUT) \ - CUR_SUBDIR=$(CUR_SUBDIR)/$(@) \ S=$(CURDIR)/$(@) \ RTE_TARGET=$(RTE_TARGET) \ $(filter-out $(DIRS-y),$(MAKECMDGOALS)) -$(RTE_SDK)/mk/rte.vars.mk: +$(BASE_OUTPUT): + $(Q)mkdir -p $(BASE_OUTPUT)/lib + $(Q)mkdir -p $(BASE_OUTPUT)/include + $(Q)mkdir -p $(BASE_OUTPUT)/app + +$(RTE_PKG_CONF): ifeq ($(RTE_SDK),$(LOCAL_RTE_SDK)) - @make RTE_TARGET=$(RTE_TARGET) config all -C $(TLDK_ROOT)/dpdk/ + @echo "== $@" + $(Q)make -C $(TLDK_ROOT)/dpdk O=$(RTE_SDK) endif diff --git a/dpdk/Makefile b/dpdk/Makefile index c474433..a4abac8 100644 --- a/dpdk/Makefile +++ b/dpdk/Makefile @@ -14,155 +14,84 @@ # Scripts require non-POSIX parts of bash SHELL := /bin/bash -DPDK_VERSION ?= v20.05 -DPDK_BUILD_DIR ?= $(CURDIR)/_build -DPDK_INSTALL_DIR ?= $(DPDK_BUILD_DIR)/dpdk/$(RTE_TARGET) -DPDK_PKTMBUF_HEADROOM ?= 128 +RTE_OUTPUT ?= $(O) + +DOWNLOAD_DIR := $(CURDIR)/downloads +MESON_DIR := $(CURDIR)/meson + +DPDK_VERSION ?= 20.11 +DPDK_SRC_DIR ?= $(RTE_OUTPUT)-src +DPDK_BUILD_DIR ?= $(RTE_OUTPUT)-build +DPDK_INSTALL_DIR ?= $(RTE_OUTPUT) DPDK_MARCH ?= native -DPDK_TUNE ?= generic -DPDK_DEBUG ?= n +DPDK_BUILD ?= release +S := $(DPDK_SRC_DIR) B := $(DPDK_BUILD_DIR) I := $(DPDK_INSTALL_DIR) -DPDK_GIT_REPO ?= http://dpdk.org/git/dpdk -DPDK_SOURCE := $(B)/dpdk -ifneq (,$(findstring clang,$(CC))) -DPDK_CC=clang -else -DPDK_CC=gcc -endif - -ifeq (,$(DPDK_TARGET)) -DPDK_TARGET := x86_64-native-linuxapp-$(DPDK_CC) -endif +DPDK_GIT_REPO ?= http://dpdk.org/git/dpdk-stable JOBS := $(shell grep processor /proc/cpuinfo | wc -l) -# compiler/linker custom arguments -DPDK_CPU_CFLAGS := -pie -fPIC -DPDK_CPU_LDFLAGS := -DPDK_EXTRA_LDFLAGS := -g - -ifeq ($(DPDK_DEBUG),n) -DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE) -else -DPDK_EXTRA_CFLAGS := -g -O0 -endif - -# translate gcc march values to DPDK arch -ifeq ($(DPDK_MARCH),native) -DPDK_MACHINE:=native # autodetect host CPU -else ifeq ($(DPDK_MARCH),corei7) -DPDK_MACHINE:=nhm # Nehalem / Westmere -else ifeq ($(DPDK_MARCH),corei7-avx) -DPDK_MACHINE:=snb # Sandy Bridge -else ifeq ($(DPDK_MARCH),core-avx-i) -DPDK_MACHINE:=ivb # Ivy Bridge -else ifeq ($(DPDK_MARCH),core-avx2) -DPDK_MACHINE:=hsw # Haswell -else ifeq ($(DPDK_MARCH),armv7a) -DPDK_MACHINE:=armv7a # ARMv7 -else ifeq ($(DPDK_MARCH),armv8a) -DPDK_MACHINE:=armv8a # ARMv8 -else -$(error Unknown DPDK_MARCH) -endif - -# assemble DPDK make arguments -DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \ - T=$(DPDK_TARGET) \ - RTE_CONFIG_TEMPLATE=../custom-config \ - RTE_OUTPUT=$(I) \ - EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \ - EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \ - CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \ - CPU_LDFLAGS="$(DPDK_CPU_LDFLAGS)" \ - $(DPDK_MAKE_EXTRA_ARGS) - -DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && \ - find $(DPDK_SOURCE) -name "*.[chS]") - -define set -@if grep -q CONFIG_$1 $@ ; \ - then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \ - else echo CONFIG_$1=$2 >> $@ ; \ -fi -endef - all: build -$(B)/custom-config: $(B)/.patch.ok Makefile - @echo --- generating custom config from \ - $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) --- $@ - @cpp -undef -ffreestanding -x assembler-with-cpp \ - $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@ - $(call set,RTE_MACHINE,$(DPDK_MACHINE)) - @# modify options - $(call set,RTE_MAX_LCORE,256) - $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM)) - $(call set,RTE_LIBEAL_USE_HPET,y) - $(call set,RTE_BUILD_COMBINE_LIBS,y) - $(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y) - $(call set,RTE_LIBRTE_I40E_ITR_INTERVAL,16) - $(call set,RTE_LIBRTE_PMD_PCAP,y) - @# enable debug init for device drivers - $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG)) - $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG)) - $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG)) - $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG)) - $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG)) - $(call set,RTE_LIBRTE_PMD_BOND,y) - $(call set,RTE_LIBRTE_IP_FRAG,y) - @# not needed - $(call set,RTE_LIBRTE_CFGFILE,n) - $(call set,RTE_LIBRTE_POWER,n) - $(call set,RTE_LIBRTE_DISTRIBUTOR,n) - $(call set,RTE_LIBRTE_REORDER,n) - $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n) - $(call set,RTE_LIBRTE_PMD_CRYPTO_SCHEDULER,n) - $(call set,RTE_KNI_KMOD,n) - @rm -f .config.ok - -$(B)/.download.ok: - @mkdir -p $(B) - @if [ -e $(DPDK_SOURCE) ] ; \ - then rm -rf $(DPDK_SOURCE) ; \ +$(S)/.download.ok: + @if [ -e $(S) ] ; \ + then rm -rf $(S) ; \ fi - @git clone $(DPDK_GIT_REPO) --branch $(DPDK_VERSION) $(DPDK_SOURCE) + $(Q)git clone $(DPDK_GIT_REPO) --branch $(DPDK_VERSION) $(S) @touch $@ .PHONY: download -download: $(B)/.download.ok +download: $(S)/.download.ok -$(B)/.patch.ok: $(B)/.download.ok +$(S)/.patch.ok: $(S)/.download.ok ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),) @echo --- patching --- for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \ echo Applying patch: $$(basename $$f) ; \ - patch -p1 -d $(DPDK_SOURCE) < $$f ; \ + patch -p1 -d $(S) < $$f ; \ done endif @touch $@ .PHONY: patch -patch: $(B)/.patch.ok - -$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config - @make $(DPDK_MAKE_ARGS) config +patch: $(S)/.patch.ok + +$(MESON_DIR)/meson.ok: + $(Q)mkdir -p $(DOWNLOAD_DIR) + $(Q)mkdir -p $(MESON_DIR) + $(Q)python3 --version + $(Q)python3 -m venv $(MESON_DIR) + $(Q)source $(MESON_DIR)/bin/activate && \ + $(Q)pip3 download -d $(DOWNLOAD_DIR) \ + meson==0.55 setuptools wheel pyelftools && \ + deactivate + $(Q)source $(MESON_DIR)/bin/activate && \ + pip3 install --no-index \ + --find-links=$(DOWNLOAD_DIR) --target=$(MESON_DIR) wheel && \ + deactivate + $(Q)source $(MESON_DIR)/bin/activate && \ + pip3 install --no-index \ + --find-links=$(DOWNLOAD_DIR) --target=$(MESON_DIR) \ + meson==0.55 pyelftools && \ + deactivate @touch $@ .PHONY: config -config: $(B)/.config.ok - -$(B)/.build.ok: $(DPDK_SOURCE_FILES) $(B)/.config.ok - @make $(DPDK_MAKE_ARGS) install - @cp $(I)/.config $(B)/.config - @touch $@ +config: patch $(MESON_DIR)/meson.ok + $(Q)source $(MESON_DIR)/bin/activate && \ + meson --prefix=$(I) --werror -Dtests=false \ + -Dbuildtype=$(DPDK_BUILD) -Dmachine=$(DPDK_MARCH) $(B) $(S) && \ + deactivate .PHONY: build -build: $(B)/.build.ok +build: config $(B)/build.ninja + $(Q)source $(MESON_DIR)/bin/activate && \ + meson install -C $(B) && \ + deactivate .PHONY: clean clean: - @rm -rf $(B) $(I) + $(Q)rm -rf $(B) $(I) $(S) diff --git a/examples/Makefile b/examples/Makefile index cf13574..60d1d11 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -19,8 +19,6 @@ ifeq ($(TLDK_ROOT),) $(error "Please define TLDK_SDK environment variable") endif -include $(RTE_SDK)/mk/rte.vars.mk - DIRS-y += l4fwd include $(TLDK_ROOT)/mk/tle.subdir.mk diff --git a/examples/l4fwd/Makefile b/examples/l4fwd/Makefile index a6e0de3..be85eac 100644 --- a/examples/l4fwd/Makefile +++ b/examples/l4fwd/Makefile @@ -11,38 +11,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -ifeq ($(RTE_TARGET),) -$(error "Please define RTE_TARGET environment variable") -endif - -ifeq ($(TLDK_ROOT),) -$(error "Please define TLDK_ROOT environment variable") -endif - -include $(RTE_SDK)/mk/rte.vars.mk - # binary name -APP = l4fwd +APP_NAME = l4fwd + +include $(TLDK_ROOT)/mk/tle.var.mk # all source are stored in SRCS-y SRCS-y += parse.c SRCS-y += pkt.c SRCS-y += main.c -CFLAGS += $(WERROR_FLAGS) -CFLAGS += -I$(RTE_OUTPUT)/include - -LDLIBS += -L$(RTE_OUTPUT)/lib -LDLIBS += -ltle_l4p -LDLIBS += -ltle_memtank -LDLIBS += -ltle_timer +LIB_DEPS += tle_l4p +LIB_DEPS += tle_memtank +LIB_DEPS += tle_timer -EXTRA_CFLAGS += -O3 -CFLAGS_parse.o += -D_GNU_SOURCE -CFLAGS_main.o += -D_GNU_SOURCE +CFLAGS_parse.c += -D_GNU_SOURCE +CFLAGS_main.c += -D_GNU_SOURCE include $(TLDK_ROOT)/mk/tle.app.mk diff --git a/examples/l4fwd/lcore.h b/examples/l4fwd/lcore.h index 8d69c4f..7ae1943 100644 --- a/examples/l4fwd/lcore.h +++ b/examples/l4fwd/lcore.h @@ -478,7 +478,7 @@ netfe_lcore_fill(struct lcore_prm prm[RTE_MAX_LCORE], return -EINVAL; } - if (rte_get_master_lcore() != lc && + if (rte_get_main_lcore() != lc && rte_eal_get_lcore_state(lc) == RUNNING) { RTE_LOG(ERR, USER1, "%s(line=%u): lcore %u already in use\n", diff --git a/examples/l4fwd/main.c b/examples/l4fwd/main.c index 57e9cfd..266228d 100644 --- a/examples/l4fwd/main.c +++ b/examples/l4fwd/main.c @@ -271,13 +271,13 @@ main(int argc, char *argv[]) sig_handle(SIGQUIT); /* launch all slave lcores. */ - RTE_LCORE_FOREACH_SLAVE(i) { + RTE_LCORE_FOREACH_WORKER(i) { if (prm[i].be.lc != NULL || prm[i].fe.max_streams != 0) rte_eal_remote_launch(lcore_main, prm + i, i); } /* launch master lcore. */ - i = rte_get_master_lcore(); + i = rte_get_main_lcore(); if (prm[i].be.lc != NULL || prm[i].fe.max_streams != 0) lcore_main(prm + i); diff --git a/lib/Makefile b/lib/Makefile index 8d61a08..9c1ca95 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -19,12 +19,17 @@ ifeq ($(TLDK_ROOT),) $(error "Please define TLDK_SDK environment variable") endif -include $(RTE_SDK)/mk/rte.vars.mk - DIRS-y += libtle_misc DIRS-y += libtle_dring DIRS-y += libtle_timer DIRS-y += libtle_memtank DIRS-y += libtle_l4p +DEPDIR-libtle_l4p += libtle_misc +DEPDIR-libtle_l4p += libtle_dring +DEPDIR-libtle_l4p += libtle_timer +DEPDIR-libtle_l4p += libtle_memtank + +libtle_l4p: $(DEPDIR-libtle_l4p) + include $(TLDK_ROOT)/mk/tle.subdir.mk diff --git a/lib/libtle_dring/Makefile b/lib/libtle_dring/Makefile index fa03e90..f91e178 100644 --- a/lib/libtle_dring/Makefile +++ b/lib/libtle_dring/Makefile @@ -11,24 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overwritten by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - # library name -LIB = libtle_dring.a - -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) - -EXPORT_MAP := tle_dring_version.map +LIB_NAME = libtle_dring -LIBABIVER := 1 +include $(TLDK_ROOT)/mk/tle.var.mk #source files SRCS-y += dring.c diff --git a/lib/libtle_l4p/Makefile b/lib/libtle_l4p/Makefile index 5c8407e..04c53ba 100644 --- a/lib/libtle_l4p/Makefile +++ b/lib/libtle_l4p/Makefile @@ -11,24 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overwritten by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - # library name -LIB = libtle_l4p.a +LIB_NAME = libtle_l4p -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) - -EXPORT_MAP := tle_l4p_version.map - -LIBABIVER := 1 +include $(TLDK_ROOT)/mk/tle.var.mk #source files SRCS-y += ctx.c @@ -52,4 +38,8 @@ DEPDIRS-y += lib/libtle_memtank DEPDIRS-y += lib/libtle_dring DEPDIRS-y += lib/libtle_timer +LIB_DEPS += tle_memtank +LIB_DEPS += tle_dring +LIB_DEPS += tle_timer + include $(TLDK_ROOT)/mk/tle.lib.mk diff --git a/lib/libtle_l4p/ctx.c b/lib/libtle_l4p/ctx.c index b810983..90dcfb5 100644 --- a/lib/libtle_l4p/ctx.c +++ b/lib/libtle_l4p/ctx.c @@ -22,7 +22,7 @@ #include "stream.h" #include "misc.h" -#include <halfsiphash.h> +#include "halfsiphash.h" #define LPORT_START 0x8000 #define LPORT_END MAX_PORT_NUM diff --git a/lib/libtle_l4p/syncookie.h b/lib/libtle_l4p/syncookie.h index 6d4372d..d0434e9 100644 --- a/lib/libtle_l4p/syncookie.h +++ b/lib/libtle_l4p/syncookie.h @@ -20,7 +20,7 @@ #include "tcp_misc.h" #include <tle_ctx.h> -#include <halfsiphash.h> +#include "halfsiphash.h" #ifdef __cplusplus extern "C" { diff --git a/lib/libtle_memtank/Makefile b/lib/libtle_memtank/Makefile index d87e320..6efa46e 100644 --- a/lib/libtle_memtank/Makefile +++ b/lib/libtle_memtank/Makefile @@ -11,24 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overwritten by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - # library name -LIB = libtle_memtank.a - -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) - -EXPORT_MAP := tle_memtank_version.map +LIB_NAME = libtle_memtank -LIBABIVER := 1 +include $(TLDK_ROOT)/mk/tle.var.mk #source files SRCS-y += memtank.c diff --git a/lib/libtle_misc/Makefile b/lib/libtle_misc/Makefile index 9fc26f9..29b6e9c 100644 --- a/lib/libtle_misc/Makefile +++ b/lib/libtle_misc/Makefile @@ -11,24 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overwritten by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - # library name -LIB = libtle_misc.a - -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) - -EXPORT_MAP := tle_misc_version.map +LIB_NAME = libtle_misc -LIBABIVER := 1 +include $(TLDK_ROOT)/mk/tle.var.mk SYMLINK-y-include += tle_dpdk_wrapper.h SYMLINK-y-include += tle_version.h diff --git a/lib/libtle_misc/tle_dpdk_wrapper.h b/lib/libtle_misc/tle_dpdk_wrapper.h index 3736964..409678d 100644 --- a/lib/libtle_misc/tle_dpdk_wrapper.h +++ b/lib/libtle_misc/tle_dpdk_wrapper.h @@ -96,11 +96,14 @@ static inline void _rte_ring_dequeue_ptrs(struct rte_ring *r, void **obj_table, uint32_t num) { uint32_t tail; - void **data; tail = r->cons.tail; - data = _rte_ring_get_data(r); +#if RTE_VERSION >= RTE_VERSION_NUM(20, 8, 0, 0) + __rte_ring_dequeue_elems(r, tail, obj_table, sizeof(obj_table[0]), num); +#else + void **data = _rte_ring_get_data(r); DEQUEUE_PTRS(r, data, tail, obj_table, num, void *); +#endif } #else diff --git a/lib/libtle_timer/Makefile b/lib/libtle_timer/Makefile index c17d219..f0867b2 100644 --- a/lib/libtle_timer/Makefile +++ b/lib/libtle_timer/Makefile @@ -11,24 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overwritten by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - # library name -LIB = libtle_timer.a - -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) - -EXPORT_MAP := tle_timer_version.map +LIB_NAME = libtle_timer -LIBABIVER := 1 +include $(TLDK_ROOT)/mk/tle.var.mk #source files SRCS-y += timer.c diff --git a/mk/tle.app.mk b/mk/tle.app.mk index 602b870..60031da 100644 --- a/mk/tle.app.mk +++ b/mk/tle.app.mk @@ -11,26 +11,47 @@ # See the License for the specific language governing permissions and # limitations under the License. -EXTLIB_BUILD := y +APP_SHARED = $(APP_NAME)-shared +APP_STATIC = $(APP_NAME)-static -# we must create the output dir first and recall the same Makefile -# from this directory -ifeq ($(NOT_FIRST_CALL),) +ifneq ($(LIB_DEPS),) + LDLIBS += -L$(RTE_OUTPUT)/lib + LDLIBS_SHARED += $(patsubst %,-l%,$(LIB_DEPS)) + LDLIBS_STATIC += $(patsubst %,-l:lib%.a,$(LIB_DEPS)) + LDFLAGS_SHARED += $(LDLIBS) $(LDLIBS_SHARED) + LDFLAGS_STATIC += $(LDLIBS) $(LDLIBS_STATIC) +endif + +.PHONY: all clean static shared +all: shared static +shared: $(RTE_OUTPUT)/app/$(APP_SHARED) +static: $(RTE_OUTPUT)/app/$(APP_STATIC) + +OBJS += $(patsubst %.c,$(BDIR)/%.o,$(SRCS-y)) -NOT_FIRST_CALL = 1 -export NOT_FIRST_CALL +$(BDIR)/%.o: %.c Makefile $(PC_FILE) + @mkdir -p $(BDIR) + $(Q)$(CC) $(CFLAGS) $(CFLAGS_$(<)) -c $< -o $@ -BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR) +SCRIPTS := $(patsubst %,$(RTE_OUTPUT)/app/%,$(SYMLINK-y-app)) -all: - $(Q)mkdir -p $(BDIR) - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) +$(RTE_OUTPUT)/app/%.py: %.py Makefile + $(Q)ln -s -f $(RTE_SRCDIR)/$< $@ + +clean: + $(Q)rm -f $(RTE_OUTPUT)/app/$(APP_SHARED) + $(Q)rm -f $(RTE_OUTPUT)/app/$(APP_STATIC) + $(Q)rm -f $(RTE_OUTPUT)/app/$(APP_NAME) + $(Q)rm -f $(SCRIPTS) + $(Q)rm -rf $(BDIR) + +$(RTE_OUTPUT)/app/$(APP_SHARED): $(SCRIPTS) $(OBJS) Makefile $(PC_FILE) +ifneq ($(OBJS),) + $(Q)$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) +endif -%:: - $(Q)mkdir -p $(BDIR) - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) -else -include $(RTE_SDK)/mk/rte.app.mk +$(RTE_OUTPUT)/app/$(APP_STATIC): $(SCRIPTS) $(OBJS) Makefile $(PC_FILE) +ifneq ($(OBJS),) + $(Q)$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) + $(Q)ln -s -f $@ $(RTE_OUTPUT)/app/$(APP_NAME) endif diff --git a/mk/tle.cpp-obj.mk b/mk/tle.cpp-obj.mk deleted file mode 100644 index 4d8a484..0000000 --- a/mk/tle.cpp-obj.mk +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 2016 Intel Corporation. -# 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. - -include $(RTE_SDK)/mk/internal/rte.compile-pre.mk -include $(RTE_SDK)/mk/internal/rte.install-pre.mk -include $(RTE_SDK)/mk/internal/rte.clean-pre.mk -include $(RTE_SDK)/mk/internal/rte.build-pre.mk -include $(TLDK_ROOT)/mk/tle.cpp-pre.mk - -# -# copy of rte.obj.mk starts here -# - -# VPATH contains at least SRCDIR -VPATH += $(SRCDIR) - -ifneq ($(OBJ),) -_BUILD = $(OBJ) -else -_BUILD = $(OBJS-y) -endif -_INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) -_CLEAN = doclean - -.PHONY: all -all: install - -.PHONY: install -install: build _postinstall - -_postinstall: build - -.PHONY: build -build: _postbuild - -ifneq ($(OBJ),) -exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1)))) - -O_TO_O = $(LD) $(CPU_LDFLAGS) -r -o $(OBJ) $(OBJS-y) -O_TO_O_STR = $(subst ','\'',$(O_TO_O)) #'# fix syntax highlight -O_TO_O_DISP = $(if $(V),"$(O_TO_O_STR)"," LD $(@)") -O_TO_O_CMD = "cmd_$@ = $(O_TO_O_STR)" -O_TO_O_DO = @set -e; \ - echo $(O_TO_O_DISP); \ - $(O_TO_O) && \ - echo $(O_TO_O_CMD) > $(call exe2cmd,$(@)) - --include .$(OBJ).cmd - -# -# Archive objects in .a file if needed -# -$(OBJ): $(OBJS-y) FORCE - @[ -d $(dir $@) ] || mkdir -p $(dir $@) - $(if $(D),\ - @echo -n "$< -> $@ " ; \ - echo -n "file_missing=$(call boolean,$(file_missing)) " ; \ - echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_O_STR))) " ; \ - echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \ - echo "depfile_newer=$(call boolean,$(depfile_newer)) ") - $(if $(or \ - $(file_missing),\ - $(call cmdline_changed,$(O_TO_O_STR)),\ - $(depfile_missing),\ - $(depfile_newer)),\ - $(O_TO_O_DO)) -endif - -# -# Clean all generated files -# -.PHONY: clean -clean: _postclean - -.PHONY: doclean -doclean: - @rm -rf $(OBJ) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \ - $(CMDS-all) $(INSTALL-FILES-all) - @rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS) - -include $(RTE_SDK)/mk/internal/rte.compile-post.mk -include $(RTE_SDK)/mk/internal/rte.install-post.mk -include $(RTE_SDK)/mk/internal/rte.clean-post.mk -include $(RTE_SDK)/mk/internal/rte.build-post.mk - -.PHONY: FORCE -FORCE: diff --git a/mk/tle.cpp-pre.mk b/mk/tle.cpp-pre.mk deleted file mode 100644 index ae7748b..0000000 --- a/mk/tle.cpp-pre.mk +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (c) 2016 Intel Corporation. -# 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. - -# convert source to obj file -src2obj = $(strip $(patsubst %.cpp,%.o,\ - $(patsubst %.S,%_s.o,$(1)))) - -# add a dot in front of the file name -dotfile = $(strip $(foreach f,$(1),\ - $(join $(dir $f),.$(notdir $f)))) - -# convert source/obj files into dot-dep filename (does not -# include .S files) -src2dep = $(strip $(call dotfile,$(patsubst %.cpp,%.o.d, \ - $(patsubst %.S,,$(1))))) -obj2dep = $(strip $(call dotfile,$(patsubst %.o,%.o.d,$(1)))) - -# convert source/obj files into dot-cmd filename -src2cmd = $(strip $(call dotfile,$(patsubst %.cpp,%.o.cmd, \ - $(patsubst %.S,%_s.o.cmd,$(1))))) -obj2cmd = $(strip $(call dotfile,$(patsubst %.o,%.o.cmd,$(1)))) - -OBJS-y := $(call src2obj,$(SRCS-y)) -OBJS-n := $(call src2obj,$(SRCS-n)) -OBJS- := $(call src2obj,$(SRCS-)) -OBJS-all := $(filter-out $(SRCS-all),$(OBJS-y) $(OBJS-n) $(OBJS-)) - -DEPS-y := $(call src2dep,$(SRCS-y)) -DEPS-n := $(call src2dep,$(SRCS-n)) -DEPS- := $(call src2dep,$(SRCS-)) -DEPS-all := $(DEPS-y) $(DEPS-n) $(DEPS-) -DEPSTMP-all := $(DEPS-all:%.d=%.d.tmp) - -CMDS-y := $(call src2cmd,$(SRCS-y)) -CMDS-n := $(call src2cmd,$(SRCS-n)) -CMDS- := $(call src2cmd,$(SRCS-)) -CMDS-all := $(CMDS-y) $(CMDS-n) $(CMDS-) - --include $(DEPS-y) $(CMDS-y) - -# command to compile a .cpp file to generate an object -ifeq ($(USE_HOST),1) -CXX_TO_O = $(HOSTCXX) -Wp,-MD,$(call obj2dep,$(@)).tmp $(HOST_CXXFLAGS) \ - $(CXXFLAGS_$(@)) $(HOST_EXTRA_CXXFLAGS) -o $@ -c $< -CXX_TO_O_STR = $(subst ','\'',$(CXX_TO_O)) #'# fix syntax highlight -CXX_TO_O_DISP = $(if $(V),"$(CXX_TO_O_STR)"," HOSTCXX $(@)") -else -CXX_TO_O = $(CXX) -Wp,-MD,$(call obj2dep,$(@)).tmp $(CXXFLAGS) \ - $(CXXFLAGS_$(@)) $(EXTRA_CXXFLAGS) -o $@ -c $< -CXX_TO_O_STR = $(subst ','\'',$(CXX_TO_O)) #'# fix syntax highlight -CXX_TO_O_DISP = $(if $(V),"$(CXX_TO_O_STR)"," CXX $(@)") -endif -CXX_TO_O_CMD = 'cmd_$@ = $(CXX_TO_O_STR)' -CXX_TO_O_DO = @set -e; \ - echo $(CXX_TO_O_DISP); \ - $(CXX_TO_O) && \ - echo $(CXX_TO_O_CMD) > $(call obj2cmd,$(@)) && \ - sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call obj2dep,$(@)) && \ - rm -f $(call obj2dep,$(@)).tmp - -# -# Compile .cpp file if needed -# Note: dep_$$@ is from the .d file and DEP_$$@ can be specified by -# user (by default it is empty) -# -#.SECONDEXPANSION: -%_cpp.o: %.cpp $$(wildcard $$(dep_$$@)) $$(DEP_$$(@)) FORCE - @[ -d $(dir $@) ] || mkdir -p $(dir $@) - $(if $(D),\ - @echo -n "$< -> $@ " ; \ - echo -n "file_missing=$(call boolean,$(file_missing)) " ; \ - echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(CXX_TO_O))) " ; \ - echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \ - echo "depfile_newer=$(call boolean,$(depfile_newer))") - $(if $(or \ - $(file_missing),\ - $(call cmdline_changed,$(CXX_TO_O)),\ - $(depfile_missing),\ - $(depfile_newer)),\ - $(CXX_TO_O_DO)) - diff --git a/mk/tle.cpp-vars.mk b/mk/tle.cpp-vars.mk deleted file mode 100644 index 9cd2e2f..0000000 --- a/mk/tle.cpp-vars.mk +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2016 Intel Corporation. -# 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. - -ifeq ($(RTE_TOOLCHAIN), clang) -CXX = $(CROSS)clang++ -ifeq ("$(origin CXX)", "command line") -HOSTCXX = $(CXX) -else -HOSTCXX = clang++ -endif -endif - -ifeq ($(RTE_TOOLCHAIN), icc) -CXX = icc -ifeq ("$(origin CXX)", "command line") -HOSTCXX = $(CXX) -else -HOSTCXX = icc -endif -endif - -ifeq ($(RTE_TOOLCHAIN), gcc) -CXX = $(CROSS)g++ -ifeq ("$(origin CXX)", "command line") -HOSTCXX = $(CXX) -else -HOSTCXX = g++ -endif -endif - -TOOLCHAIN_CXXFLAGS = - -CXXFLAGS := $(CFLAGS) - -export CXX CXXFLAGS TOOLCHAIN_CXXFLAGS diff --git a/mk/tle.lib.mk b/mk/tle.lib.mk index 7455585..90bc989 100644 --- a/mk/tle.lib.mk +++ b/mk/tle.lib.mk @@ -11,26 +11,45 @@ # See the License for the specific language governing permissions and # limitations under the License. -EXTLIB_BUILD := y +LIB_SHARED = $(LIB_NAME).so +LIB_STATIC = $(LIB_NAME).a -# we must create the output dir first and recall the same Makefile -# from this directory -ifeq ($(NOT_FIRST_CALL),) +LDFLAGS += -Wl,--no-undefined $(LDFLAGS_SHARED) -NOT_FIRST_CALL = 1 -export NOT_FIRST_CALL +ifneq ($(LIB_DEPS),) + LDLIBS += -L$(RTE_OUTPUT)/lib + LDLIBS += $(patsubst %,-l%,$(LIB_DEPS)) + LDFLAGS += $(LDLIBS) +endif + +.PHONY: all clean static shared +all: shared static +shared: $(RTE_OUTPUT)/lib/$(LIB_SHARED) +static: $(RTE_OUTPUT)/lib/$(LIB_STATIC) + +OBJS := $(patsubst %.c,$(BDIR)/%.o,$(SRCS-y)) + +$(BDIR)/%.o: %.c Makefile $(HDRS) $(PC_FILE) + @mkdir -p $(BDIR) + $(Q)$(CC) $(CFLAGS) -c $< -o $@ -BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR) +HDRS := $(patsubst %.h,$(RTE_OUTPUT)/include/%.h,$(SYMLINK-y-include)) -all: - $(Q)mkdir -p $(BDIR) - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) +$(RTE_OUTPUT)/include/%.h: %.h Makefile $(PC_FILE) + $(Q)ln -s -f $(RTE_SRCDIR)/$< $@ + +clean: + $(Q)rm -f $(RTE_OUTPUT)/lib/$(LIB_SHARED) + $(Q)rm -f $(RTE_OUTPUT)/lib/$(LIB_STATIC) + $(Q)rm -f $(HDRS) + $(Q)rm -rf $(BDIR) + +$(RTE_OUTPUT)/lib/$(LIB_SHARED): $(HDRS) $(OBJS) Makefile $(PC_FILE) +ifneq ($(OBJS),) + $(Q)$(CC) $(OBJS) -o $@ -shared $(LDFLAGS) +endif -%:: - $(Q)mkdir -p $(BDIR) - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) -else -include $(RTE_SDK)/mk/rte.lib.mk +$(RTE_OUTPUT)/lib/$(LIB_STATIC): $(HDRS) $(OBJS) Makefile $(PC_FILE) +ifneq ($(OBJS),) + $(Q)$(AR) -cr $@ $(OBJS) -o $@ endif diff --git a/mk/tle.subdir.mk b/mk/tle.subdir.mk index 772011a..ce45acb 100644 --- a/mk/tle.subdir.mk +++ b/mk/tle.subdir.mk @@ -19,11 +19,12 @@ clean: $(DIRS-y) .PHONY: $(DIRS-y) $(DIRS-y): - @echo "== $@" + @echo "=> $@" $(Q)$(MAKE) -C $(@) \ + O=$(O) \ M=$(CURDIR)/$(@)/Makefile \ - CUR_SUBDIR=$(CUR_SUBDIR)/$(@) \ S=$(CURDIR)/$(@) \ RTE_TARGET=$(RTE_TARGET) \ $(filter-out $(DIRS-y),$(MAKECMDGOALS)) + @echo "<= $@" diff --git a/mk/tle.var.mk b/mk/tle.var.mk new file mode 100644 index 0000000..673c1d0 --- /dev/null +++ b/mk/tle.var.mk @@ -0,0 +1,58 @@ +# Copyright (c) 2021 Intel Corporation. +# 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. + +ifeq ($(RTE_SDK),) +$(error "Please define RTE_SDK environment variable") +endif + +# Default target, can be overwritten by command line or environment +RTE_TARGET ?= x86_64-native-linuxapp-gcc +RTE_OUTPUT ?= $(O) +RTE_SRCDIR ?= $(S) + +RTE_PKGCONF ?= $(RTE_SDK)/lib/x86_64-linux-gnu/pkgconfig + +PKGCONF = export PKG_CONFIG_PATH=$(RTE_PKGCONF); \ + pkg-config +ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) +$(error "no installation of DPDK found") +endif + +CFLAGS += -O3 +CFLAGS += -fPIC +CFLAGS += -m64 -pthread +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -I$(RTE_OUTPUT)/include + +# compiler errors/warnings +ifeq ($(CC), clang) +CFLAGS += -Wall -Wextra -Werror +CFLAGS += -Wno-missing-field-initializers -Wno-implicit-fallthrough +CFLAGS += -Wno-address-of-packed-member -Wno-gnu-alignof-expression +CFLAGS += -Wno-constant-conversion +else +CFLAGS += -Wall -Wextra -Werror +CFLAGS += -Wno-missing-field-initializers -Wimplicit-fallthrough=2 +CFLAGS += -Wno-format-truncation -Wno-address-of-packed-member +endif + +PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) +CFLAGS += $(shell $(PKGCONF) --cflags libdpdk) +LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) +LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) + +ifneq ($(APP_NAME),) + BDIR := $(RTE_OUTPUT)/build/$(APP_NAME) +else + BDIR := $(RTE_OUTPUT)/build/$(LIB_NAME) +endif diff --git a/test/Makefile b/test/Makefile index c82b123..777b440 100644 --- a/test/Makefile +++ b/test/Makefile @@ -19,8 +19,6 @@ ifeq ($(TLDK_ROOT),) $(error "Please define TLDK_SDK environment variable") endif -include $(RTE_SDK)/mk/rte.vars.mk - DIRS-y += dring DIRS-y += gtest DIRS-y += memtank diff --git a/test/dring/Makefile b/test/dring/Makefile index 6549744..8141512 100644 --- a/test/dring/Makefile +++ b/test/dring/Makefile @@ -11,32 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -ifeq ($(RTE_TARGET),) -$(error "Please define RTE_TARGET environment variable") -endif - -ifeq ($(TLDK_ROOT),) -$(error "Please define TLDK_ROOT environment variable") -endif - -include $(RTE_SDK)/mk/rte.vars.mk - # binary name -APP = test_dring +APP_NAME = test_dring + +include $(TLDK_ROOT)/mk/tle.var.mk # all source are stored in SRCS-y SRCS-y += test_dring.c -CFLAGS += $(WERROR_FLAGS) -CFLAGS += -I$(RTE_OUTPUT)/include - -LDLIBS += -L$(RTE_OUTPUT)/lib -LDLIBS += -ltle_dring - -EXTRA_CFLAGS += -O3 +LIB_DEPS += tle_dring include $(TLDK_ROOT)/mk/tle.app.mk diff --git a/test/dring/test_dring.c b/test/dring/test_dring.c index 692fd44..a84081a 100644 --- a/test/dring/test_dring.c +++ b/test/dring/test_dring.c @@ -405,7 +405,7 @@ test_dring_mt(int32_t master_enq_type, int32_t master_deq_type, memset(arg, 0, sizeof(arg)); /* launch on all slaves */ - RTE_LCORE_FOREACH_SLAVE(lc) { + RTE_LCORE_FOREACH_WORKER(lc) { arg[lc].dr = &dr; arg[lc].r = r; arg[lc].iter = ITER_NUM; @@ -426,7 +426,7 @@ test_dring_mt(int32_t master_enq_type, int32_t master_deq_type, deq = arg[lc].deq; /* wait for slaves. */ - RTE_LCORE_FOREACH_SLAVE(lc) { + RTE_LCORE_FOREACH_WORKER(lc) { rc |= rte_eal_wait_lcore(lc); enq += arg[lc].enq; deq += arg[lc].deq; diff --git a/test/gtest/Makefile b/test/gtest/Makefile index 3858306..0d6372e 100644 --- a/test/gtest/Makefile +++ b/test/gtest/Makefile @@ -11,10 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - ifeq ($(GTEST_DIR),) all: @echo "GTEST_DIR is not setup properly. Skipping gtest" @@ -24,111 +20,46 @@ all: else -# Default target, can be overridden by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - -CUR_SUBDIR ?= . - -# we must create the output dir first and recall the same Makefile -# from this directory -ifeq ($(NOT_FIRST_CALL),) - -NOT_FIRST_CALL = 1 -export NOT_FIRST_CALL - - -BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR) - -all: - $(Q)mkdir -p $(BDIR) - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=obj - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=app - -%:: - $(Q)mkdir -p $(BDIR) - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=obj - $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \ - S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=app -else - -# -# building object -# - -ifeq ($(X),obj) -include $(TLDK_ROOT)/mk/tle.cpp-vars.mk - # binary name -OBJ = gtest-rfc.o +APP_NAME = gtest-rfc + +include $(TLDK_ROOT)/mk/tle.var.mk # all source are stored in SRCS-y -SRCS-y += main.cpp -SRCS-y += test_common.cpp -SRCS-y += test_tle_dring.cpp -SRCS-y += test_tle_ctx.cpp -#SRCS-y += test_tle_udp_dev.cpp -SRCS-y += test_tle_udp_destroy.cpp -SRCS-y += test_tle_udp_event.cpp -#SRCS-y += test_tle_udp_stream.cpp -SRCS-y += test_tle_udp_stream_gen.cpp -SRCS-y += test_tle_tcp_stream.cpp -#SRCS-y += test_tle_tcp_stream_gen.cpp +SRCCPP-y += main.cpp +SRCCPP-y += test_common.cpp +SRCCPP-y += test_tle_dring.cpp +SRCCPP-y += test_tle_ctx.cpp +SRCCPP-y += test_tle_udp_destroy.cpp +SRCCPP-y += test_tle_udp_event.cpp +SRCCPP-y += test_tle_udp_stream_gen.cpp +SRCCPP-y += test_tle_tcp_stream.cpp SYMLINK-y-app += test_scapy_gen.py CXXFLAGS += -std=c++11 -ifeq ($(shell test $(GCC_VERSION) -lt 50 && echo 1), 1) -CXXFLAGS += -D __STDC_FORMAT_MACROS -endif - CXXFLAGS += -I$(GTEST_DIR)/include CXXFLAGS += -I$(GMOCK_DIR)/include -CXXFLAGS += -I$(RTE_OUTPUT)/include -CXXFLAGS += $(EXTRA_CFLAGS) +CXXFLAGS += $(CFLAGS) -Wno-error -LDFLAGS += -lstdc++ +LDFLAGS += -lstdc++ -lpthread LDFLAGS += -L$(GMOCK_DIR) -L$(GMOCK_DIR)/../lib -lgmock -LDLIBS += -whole-archive -ltle_l4p -ltle_dring - -include $(TLDK_ROOT)/mk/tle.cpp-obj.mk -endif - -# -# building app -# - -ifeq ($(X),app) +LDFLAGS += -L$(GMOCK_DIR)/gtest -L$(GMOCK_DIR)/../lib -lgtest -# binary name -APP = gtest-rfc - -# all source are stored in SRCS-y +LIB_DEPS += tle_l4p +LIB_DEPS += tle_memtank +LIB_DEPS += tle_timer +LIB_DEPS += tle_dring -CFLAGS += -O3 - -ifeq ($(shell test $(GCC_VERSION) -lt 50 && echo 1), 1) -CFLAGS += -D __STDC_FORMAT_MACROS -endif +CPP_OBJS := $(patsubst %.cpp,$(BDIR)/%.o,$(SRCCPP-y)) +OBJS += $(CPP_OBJS) -CFLAGS += $(WERROR_FLAGS) - -LDLIBS += gtest-rfc.o - -LDLIBS += -lstdc++ -LDLIBS += -L$(GMOCK_DIR) -L$(GMOCK_DIR)/../lib -lgmock -LDLIBS += -L$(GMOCK_DIR)/gtest -L$(GMOCK_DIR)/../lib -lgtest -LDLIBS += -L$(RTE_OUTPUT)/lib -LDLIBS += -whole-archive -ltle_l4p -ltle_dring -ltle_memtank -ltle_timer +$(BDIR)/%.o: %.cpp Makefile + @mkdir -p $(BDIR) + $(Q)$(CXX) $(CXXFLAGS) $(CXXFLAGS_$(<)) -c $< -o $@ include $(TLDK_ROOT)/mk/tle.app.mk -endif endif -endif diff --git a/test/gtest/test_tle_dring.h b/test/gtest/test_tle_dring.h index fdb2c47..1988e9f 100644 --- a/test/gtest/test_tle_dring.h +++ b/test/gtest/test_tle_dring.h @@ -384,7 +384,7 @@ test_dring_mt(int32_t master_enq_type, int32_t master_deq_type, memset(arg, 0, sizeof(arg)); /* launch on all slaves */ - RTE_LCORE_FOREACH_SLAVE(lc) { + RTE_LCORE_FOREACH_WORKER(lc) { arg[lc].dr = &dr; arg[lc].r = r; arg[lc].iter = ITER_NUM; @@ -405,7 +405,7 @@ test_dring_mt(int32_t master_enq_type, int32_t master_deq_type, deq = arg[lc].deq; /* wait for slaves. */ - RTE_LCORE_FOREACH_SLAVE(lc) { + RTE_LCORE_FOREACH_WORKER(lc) { rc |= rte_eal_wait_lcore(lc); enq += arg[lc].enq; deq += arg[lc].deq; diff --git a/test/memtank/Makefile b/test/memtank/Makefile index b8e4483..5a508c0 100644 --- a/test/memtank/Makefile +++ b/test/memtank/Makefile @@ -11,32 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -ifeq ($(RTE_TARGET),) -$(error "Please define RTE_TARGET environment variable") -endif - -ifeq ($(TLDK_ROOT),) -$(error "Please define TLDK_ROOT environment variable") -endif - -include $(RTE_SDK)/mk/rte.vars.mk - # binary name -APP = test_memtank +APP_NAME = test_memtank + +include $(TLDK_ROOT)/mk/tle.var.mk # all source are stored in SRCS-y SRCS-y += test_memtank.c -CFLAGS += $(WERROR_FLAGS) -CFLAGS += -I$(RTE_OUTPUT)/include - -LDLIBS += -L$(RTE_OUTPUT)/lib -LDLIBS += -ltle_memtank - -EXTRA_CFLAGS += -O3 +LIB_DEPS += tle_memtank include $(TLDK_ROOT)/mk/tle.app.mk diff --git a/test/memtank/test_memtank.c b/test/memtank/test_memtank.c index 6312339..899cc5a 100644 --- a/test/memtank/test_memtank.c +++ b/test/memtank/test_memtank.c @@ -703,7 +703,7 @@ test_memtank_cleanup(struct tle_memtank *mt, struct memstat *ms, printf("%s(%s)\n", __func__, tname); - RTE_LCORE_FOREACH_SLAVE(lc) + RTE_LCORE_FOREACH_WORKER(lc) rte_eal_remote_launch(test_worker_cleanup, &arg[lc], lc); /* launch on master */ @@ -711,8 +711,9 @@ test_memtank_cleanup(struct tle_memtank *mt, struct memstat *ms, arg[lc].master.run_cycles = CLEANUP_TIME * rte_get_timer_hz(); test_memtank_master(&arg[lc]); + rc = 0; ms->nb_alloc_obj = 0; - RTE_LCORE_FOREACH_SLAVE(lc) { + RTE_LCORE_FOREACH_WORKER(lc) { rc |= rte_eal_wait_lcore(lc); ms->nb_alloc_obj += arg[lc].stats.alloc.nb_alloc - arg[lc].stats.free.nb_free; @@ -764,7 +765,7 @@ test_memtank_mt(const char *tname, uint32_t alloc_flags, uint32_t free_flags) memset(arg, 0, sizeof(arg)); /* prepare args on all slaves */ - RTE_LCORE_FOREACH_SLAVE(lc) { + RTE_LCORE_FOREACH_WORKER(lc) { arg[lc].mt = mt; rc = fill_worker_args(&arg[lc].worker, alloc_flags, free_flags, lc); @@ -779,7 +780,7 @@ test_memtank_mt(const char *tname, uint32_t alloc_flags, uint32_t free_flags) } /* launch on all slaves */ - RTE_LCORE_FOREACH_SLAVE(lc) + RTE_LCORE_FOREACH_WORKER(lc) rte_eal_remote_launch(test_memtank_worker, &arg[lc], lc); /* launch on master */ @@ -794,7 +795,7 @@ test_memtank_mt(const char *tname, uint32_t alloc_flags, uint32_t free_flags) memtank_stat_reset(&wrk_stats); rc = 0; - RTE_LCORE_FOREACH_SLAVE(lc) { + RTE_LCORE_FOREACH_WORKER(lc) { rc |= rte_eal_wait_lcore(lc); memtank_stat_dump(stdout, lc, &arg[lc].stats); memtank_stat_aggr(&wrk_stats, &arg[lc].stats); diff --git a/test/timer/Makefile b/test/timer/Makefile index 159faeb..5e3c1ef 100644 --- a/test/timer/Makefile +++ b/test/timer/Makefile @@ -11,32 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -ifeq ($(RTE_TARGET),) -$(error "Please define RTE_TARGET environment variable") -endif - -ifeq ($(TLDK_ROOT),) -$(error "Please define TLDK_ROOT environment variable") -endif - -include $(RTE_SDK)/mk/rte.vars.mk - # binary name -APP = test_timer +APP_NAME = test_timer + +include $(TLDK_ROOT)/mk/tle.var.mk # all source are stored in SRCS-y SRCS-y += test_timer.c -CFLAGS += $(WERROR_FLAGS) -CFLAGS += -I$(RTE_OUTPUT)/include - -LDLIBS += -L$(RTE_OUTPUT)/lib -LDLIBS += -ltle_timer - -EXTRA_CFLAGS += -O3 +LIB_DEPS += tle_timer include $(TLDK_ROOT)/mk/tle.app.mk |