1155 lines
39 KiB
Diff
1155 lines
39 KiB
Diff
From 871a94d0abdf14efb9dfe42b711acc37d842ce6d Mon Sep 17 00:00:00 2001
|
|
From: Lemmy Huang <huangliming5@huawei.com>
|
|
Date: Mon, 8 Jul 2024 20:35:10 +0800
|
|
Subject: [PATCH] cleancode: improving makefile readability
|
|
|
|
Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
|
|
---
|
|
build/build.sh | 8 +-
|
|
src/common/dir.mk | 13 ---
|
|
src/lstack/Makefile | 92 +++++++--------
|
|
src/lstack/Printlog.mk | 14 +++
|
|
src/lstack/api/dir.mk | 14 ---
|
|
src/lstack/api/lstack_epoll.c | 4 +-
|
|
src/lstack/api/lstack_rtw_api.c | 2 +-
|
|
src/lstack/api/lstack_signal.c | 4 +-
|
|
src/lstack/api/lstack_wrap.c | 3 +-
|
|
src/lstack/core/dir.mk | 13 ---
|
|
src/lstack/core/lstack_cfg.c | 5 +-
|
|
src/lstack/core/lstack_control_plane.c | 4 +-
|
|
src/lstack/core/lstack_dpdk.c | 3 +-
|
|
src/lstack/core/lstack_init.c | 5 +-
|
|
src/lstack/core/lstack_lwip.c | 4 +-
|
|
src/lstack/core/lstack_preload.c | 1 -
|
|
src/lstack/core/lstack_protocol_stack.c | 6 +-
|
|
src/lstack/core/lstack_stack_stat.c | 4 +-
|
|
src/lstack/include/lstack_cfg.h | 2 +-
|
|
src/lstack/include/lstack_dpdk.h | 4 +-
|
|
src/lstack/include/lstack_fault_inject.h | 2 +
|
|
src/lstack/include/lstack_lwip.h | 2 +-
|
|
src/lstack/include/lstack_protocol_stack.h | 4 +-
|
|
src/lstack/include/posix/lstack_epoll.h | 4 +-
|
|
src/lstack/netif/dir.mk | 15 ---
|
|
src/lstack/netif/lstack_ethdev.c | 2 +-
|
|
src/lstack/netif/lstack_fault_inject.c | 4 +
|
|
src/lstack/netif/lstack_flow.c | 2 +-
|
|
src/lstack/netif/lstack_tx_cache.c | 2 +-
|
|
src/lstack/netif/lstack_vdev.c | 4 +-
|
|
src/ltran/CMakeLists.txt | 127 ++++++++++++---------
|
|
src/ltran/ltran_base.h | 2 +-
|
|
src/ltran/ltran_dfx.c | 2 +-
|
|
src/ltran/ltran_ethdev.c | 6 +-
|
|
src/ltran/ltran_ethdev.h | 2 +-
|
|
src/ltran/ltran_forward.c | 2 +-
|
|
src/ltran/ltran_instance.c | 6 +-
|
|
src/ltran/ltran_instance.h | 4 +-
|
|
src/ltran/ltran_monitor.c | 4 +-
|
|
src/ltran/ltran_param.c | 4 +-
|
|
src/ltran/ltran_param.h | 2 +-
|
|
src/ltran/ltran_stack.c | 2 +-
|
|
src/ltran/ltran_stat.c | 4 +-
|
|
src/ltran/ltran_stat.h | 2 +-
|
|
src/ltran/ltran_tcp_conn.h | 2 +-
|
|
src/ltran/ltran_tcp_sock.c | 2 +-
|
|
src/ltran/ltran_tcp_sock.h | 2 +-
|
|
src/ltran/main.c | 2 +-
|
|
48 files changed, 200 insertions(+), 223 deletions(-)
|
|
delete mode 100644 src/common/dir.mk
|
|
create mode 100644 src/lstack/Printlog.mk
|
|
delete mode 100644 src/lstack/api/dir.mk
|
|
delete mode 100644 src/lstack/core/dir.mk
|
|
delete mode 100644 src/lstack/netif/dir.mk
|
|
|
|
diff --git a/build/build.sh b/build/build.sh
|
|
index 622e1cc..ed6d444 100755
|
|
--- a/build/build.sh
|
|
+++ b/build/build.sh
|
|
@@ -12,8 +12,10 @@
|
|
export CURRENT_PATH=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
|
|
cd $CURRENT_PATH
|
|
|
|
+cpu_num=8
|
|
+
|
|
make -C ../src/lstack clean
|
|
-make -C ../src/lstack
|
|
+make -C ../src/lstack -j${cpu_num}
|
|
if [ $? -ne 0 ]; then
|
|
echo "build lstack failed"
|
|
exit 1
|
|
@@ -24,7 +26,7 @@ rm -f CMakeCache.txt
|
|
rm -f ltran gazellectl
|
|
rm -rf CMakeFiles
|
|
cmake .
|
|
-make
|
|
+make -j${cpu_num}
|
|
if [ $? -ne 0 ]; then
|
|
echo "build ltran failed"
|
|
exit 1
|
|
@@ -33,7 +35,7 @@ fi
|
|
cd -
|
|
cd ../examples
|
|
cmake .
|
|
-make
|
|
+make -j${cpu_num}
|
|
if [ $? -ne 0 ]; then
|
|
echo "build examples failed"
|
|
exit 1
|
|
diff --git a/src/common/dir.mk b/src/common/dir.mk
|
|
deleted file mode 100644
|
|
index 68a2b72..0000000
|
|
--- a/src/common/dir.mk
|
|
+++ /dev/null
|
|
@@ -1,13 +0,0 @@
|
|
-# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
|
-# gazelle is licensed under the Mulan PSL v2.
|
|
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
-# You may obtain a copy of Mulan PSL v2 at:
|
|
-# http://license.coscl.org.cn/MulanPSL2
|
|
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
-# PURPOSE.
|
|
-# See the Mulan PSL v2 for more details.
|
|
-
|
|
-SRC = dpdk_common.c gazelle_parse_config.c
|
|
-$(eval $(call register_dir, ../common, $(SRC)))
|
|
-
|
|
diff --git a/src/lstack/Makefile b/src/lstack/Makefile
|
|
index ace33bd..dd4e2c4 100644
|
|
--- a/src/lstack/Makefile
|
|
+++ b/src/lstack/Makefile
|
|
@@ -7,40 +7,28 @@
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
# PURPOSE.
|
|
# See the Mulan PSL v2 for more details.
|
|
-LSTACK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
-ROOT_DIR := $(dir $(abspath $(LSTACK_DIR)))
|
|
+ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
+
|
|
+include $(ROOT_DIR)/Printlog.mk
|
|
|
|
-LWIP_INCLUDE_FILE ?= /usr/include/lwip
|
|
LIB_PATH ?= /usr/lib64
|
|
+LWIP_INCLUDE_DIR ?= /usr/include/lwip
|
|
|
|
DPDK_VERSION := $(shell rpm -q --queryformat '%{VERSION}' dpdk)
|
|
ifeq ($(DPDK_VERSION),21.11)
|
|
- DPDK_INCLUDE_FILE := /usr/local/include
|
|
+ DPDK_INCLUDE_DIR := /usr/local/include
|
|
else
|
|
- DPDK_INCLUDE_FILE := /usr/include/dpdk
|
|
+ DPDK_INCLUDE_DIR := /usr/include/dpdk
|
|
endif
|
|
|
|
AR = ar
|
|
ARFLAGS = crDP
|
|
CC ?= gcc
|
|
-OPTIMIZATION = -O2 -g
|
|
RM = rm -f
|
|
-LDFLAGS = -shared -ldl -lm -lpthread -lrt -lnuma -lconfig -lboundscheck
|
|
ARCH := $(shell uname -m)
|
|
|
|
-ifneq ($(CC),clang)
|
|
- SEC_FLAGS = -fstack-protector-strong -Werror -Wall -Wno-deprecated-declarations -Wl,-z,relro, -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -fPIC -D_FORTIFY_SOURCE=2
|
|
-else
|
|
- SEC_FLAGS = -fstack-protector-strong -Werror -Wall -Wno-deprecated-declarations -fPIC
|
|
-endif
|
|
-$(info $(CC):$(SEC_FLAGS))
|
|
-
|
|
-INC = -I$(LSTACK_DIR)/include \
|
|
- -I$(LSTACK_DIR)/../common \
|
|
- -I$(LWIP_INCLUDE_FILE) \
|
|
- -I$(DPDK_INCLUDE_FILE)
|
|
-
|
|
-CFLAGS += $(OPTIMIZATION) -fno-strict-aliasing $(INC) -Wno-error=unused-function
|
|
+CFLAGS = -O2 -g
|
|
+LDFLAGS = -shared -ldl -lm -lpthread -lrt -lnuma -lconfig -lboundscheck
|
|
|
|
ifeq ($(GAZELLE_COVERAGE_ENABLE), 1)
|
|
LDFLAGS += -fprofile-arcs -ftest-coverage
|
|
@@ -48,7 +36,6 @@ ifeq ($(GAZELLE_COVERAGE_ENABLE), 1)
|
|
endif
|
|
|
|
ifeq ($(GAZELLE_FAULT_INJECT_ENABLE), 1)
|
|
- LDFLAGS += -DGAZELLE_FAULT_INJECT_ENABLE
|
|
CFLAGS += -DGAZELLE_FAULT_INJECT_ENABLE
|
|
endif
|
|
|
|
@@ -56,19 +43,21 @@ ifeq ($(shell $(CC) -dumpmachine | cut -d"-" -f1), x86_64)
|
|
CFLAGS += -mssse3
|
|
endif
|
|
|
|
-CFLAGS += $(SEC_FLAGS)
|
|
-
|
|
-SRCS =
|
|
-DIRS = core netif api ../common
|
|
+SEC_FLAGS = -Wall -Werror -fstack-protector-strong -Wno-deprecated-declarations -fPIC
|
|
+ifneq ($(CC),clang)
|
|
+ SEC_FLAGS += -Wl,-z,relro, -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -D_FORTIFY_SOURCE=2
|
|
+endif
|
|
|
|
-define register_dir
|
|
-SRCS += $(patsubst %, $(1)/%, $(2))
|
|
-endef
|
|
+INC = -I$(ROOT_DIR)/include \
|
|
+ -I$(ROOT_DIR)/../ \
|
|
+ -I$(LWIP_INCLUDE_DIR) \
|
|
+ -I$(DPDK_INCLUDE_DIR)
|
|
|
|
-include $(patsubst %, %/dir.mk, $(DIRS))
|
|
+CFLAGS += -fno-strict-aliasing -Wno-error=unused-function
|
|
+CFLAGS += -D__USE_GNU=1 -D_GNU_SOURCE=1
|
|
+CFLAGS += $(SEC_FLAGS)
|
|
+CFLAGS += $(INC)
|
|
|
|
-# Linking object and library
|
|
-OBJS = $(subst .c,.o,$(SRCS))
|
|
|
|
LWIP_LIB = $(LIB_PATH)/liblwip.a
|
|
LIBRTE_LIB = $(LIB_PATH)/librte_pci.so \
|
|
@@ -98,9 +87,9 @@ ifeq ($(DPDK_VERSION), 19.11)
|
|
$(LIB_PATH)/librte_pmd_hinic.so \
|
|
$(LIB_PATH)/librte_pmd_ixgbe.so \
|
|
$(LIB_PATH)/librte_pmd_virtio.so
|
|
- ifneq ($(ARCH), loongarch64)
|
|
- LIBRTE_LIB += $(LIB_PATH)/librte_pmd_i40e.so
|
|
- endif
|
|
+ ifneq ($(ARCH), loongarch64)
|
|
+ LIBRTE_LIB += $(LIB_PATH)/librte_pmd_i40e.so
|
|
+ endif
|
|
else
|
|
LIBRTE_LIB += $(LIB_PATH)/librte_net_pcap.so \
|
|
$(LIB_PATH)/librte_net_bond.so \
|
|
@@ -109,31 +98,38 @@ else
|
|
$(LIB_PATH)/librte_net_virtio.so \
|
|
$(LIB_PATH)/librte_telemetry.so \
|
|
$(LIB_PATH)/librte_pcapng.so
|
|
- ifeq ($(filter loongarch64 riscv64, $(ARCH)),)
|
|
- LIBRTE_LIB += $(LIB_PATH)/librte_net_i40e.so
|
|
- endif
|
|
+ ifeq ($(filter loongarch64 riscv64, $(ARCH)),)
|
|
+ LIBRTE_LIB += $(LIB_PATH)/librte_net_i40e.so
|
|
+ endif
|
|
endif
|
|
|
|
DEP_LIBS = $(LWIP_LIB) $(LIBRTE_LIB)
|
|
+$(info $(CC):$(DEP_LIBS))
|
|
+
|
|
+SRCS = $(wildcard ./api/*.c ./core/*.c ./netif/*.c ../common/*.c)
|
|
+# Linking object and library
|
|
+OBJS = $(subst .c,.o,$(SRCS))
|
|
+
|
|
LDFLAGS += -Wl,--whole-archive $(DEP_LIBS) $(OBJS) -Wl,--no-whole-archive
|
|
|
|
+$(info [CFLAGS] $(CFLAGS))
|
|
+$(info [LDFLAGS] $(LDFLAGS))
|
|
+
|
|
# Target
|
|
LSTACK_SHARED_LIB = liblstack.so
|
|
LSTACK_STATIC_LIB = liblstack.a
|
|
|
|
-.PHONY: all
|
|
+.PHONY: all clean
|
|
all: $(LSTACK_SHARED_LIB)
|
|
|
|
-depend: .depend
|
|
-
|
|
-.depend: $(SRCS)
|
|
- rm -f ./.depend
|
|
- $(foreach SRC,$(SRCS),$(CC) $(CFLAGS) -MM -MT $(SRC:.c=.o) $(SRC) >> .depend;)
|
|
-
|
|
--include .depend
|
|
-
|
|
$(LSTACK_SHARED_LIB): $(OBJS)
|
|
- $(CC) $(LDFLAGS) -Wl,--whole-archive -Wl,--no-whole-archive -o $@
|
|
+ $(call printlog, BUILD, $@)
|
|
+ $(QUIET) $(CC) $(LDFLAGS) -o $@
|
|
+
|
|
+%.o: %.c
|
|
+ $(call printlog, BUILD, $@)
|
|
+ $(QUIET) $(CC) $(CFLAGS) -c $(filter %.c,$^) -o $@
|
|
|
|
clean:
|
|
- $(RM) $(LSTACK_SHARED_LIB) $(OBJS) .depend
|
|
+ $(call printlog, CLEAN, $(LSTACK_SHARED_LIB))
|
|
+ $(QUIET) $(RM) $(LSTACK_SHARED_LIB) $(OBJS)
|
|
diff --git a/src/lstack/Printlog.mk b/src/lstack/Printlog.mk
|
|
new file mode 100644
|
|
index 0000000..7604851
|
|
--- /dev/null
|
|
+++ b/src/lstack/Printlog.mk
|
|
@@ -0,0 +1,14 @@
|
|
+
|
|
+ROOT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
+
|
|
+ifeq ($(V),1)
|
|
+ QUIET =
|
|
+ printlog =
|
|
+else
|
|
+ QUIET = @
|
|
+ printlog = @printf ' %-8s %s%s\n' \
|
|
+ "$(1)" \
|
|
+ "$(patsubst $(ROOT_DIR)/%,%,$(2))" \
|
|
+ "$(if $(3), $(3))";
|
|
+ MAKEFLAGS += --no-print-directory
|
|
+endif
|
|
diff --git a/src/lstack/api/dir.mk b/src/lstack/api/dir.mk
|
|
deleted file mode 100644
|
|
index 729690d..0000000
|
|
--- a/src/lstack/api/dir.mk
|
|
+++ /dev/null
|
|
@@ -1,14 +0,0 @@
|
|
-# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
|
-# gazelle is licensed under the Mulan PSL v2.
|
|
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
-# You may obtain a copy of Mulan PSL v2 at:
|
|
-# http://license.coscl.org.cn/MulanPSL2
|
|
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
-# PURPOSE.
|
|
-# See the Mulan PSL v2 for more details.
|
|
-
|
|
-SRC = lstack_epoll.c lstack_signal.c lstack_fork.c lstack_wrap.c lstack_rtw_api.c lstack_rtc_api.c lstack_dummy_api.c
|
|
-
|
|
-$(eval $(call register_dir, api, $(SRC)))
|
|
-
|
|
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
|
|
index 2ac7150..9c0aef7 100644
|
|
--- a/src/lstack/api/lstack_epoll.c
|
|
+++ b/src/lstack/api/lstack_epoll.c
|
|
@@ -31,8 +31,8 @@
|
|
#include "lstack_stack_stat.h"
|
|
#include "lstack_cfg.h"
|
|
#include "lstack_log.h"
|
|
-#include "dpdk_common.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/dpdk_common.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_lwip.h"
|
|
#include "lstack_protocol_stack.h"
|
|
#include "posix/lstack_epoll.h"
|
|
diff --git a/src/lstack/api/lstack_rtw_api.c b/src/lstack/api/lstack_rtw_api.c
|
|
index e50fe37..e43be59 100644
|
|
--- a/src/lstack/api/lstack_rtw_api.c
|
|
+++ b/src/lstack/api/lstack_rtw_api.c
|
|
@@ -22,7 +22,7 @@
|
|
#include "lstack_protocol_stack.h"
|
|
#include "lstack_cfg.h"
|
|
#include "lstack_lwip.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_rtw_api.h"
|
|
|
|
|
|
diff --git a/src/lstack/api/lstack_signal.c b/src/lstack/api/lstack_signal.c
|
|
index 314c14c..3dd5d03 100644
|
|
--- a/src/lstack/api/lstack_signal.c
|
|
+++ b/src/lstack/api/lstack_signal.c
|
|
@@ -18,9 +18,9 @@
|
|
#include <lwip/lwipsock.h>
|
|
#include <lwip/posix_api.h>
|
|
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_cfg.h"
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "lstack_log.h"
|
|
#include "lstack_control_plane.h"
|
|
|
|
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
|
|
index 7101d98..3a60cbb 100644
|
|
--- a/src/lstack/api/lstack_wrap.c
|
|
+++ b/src/lstack/api/lstack_wrap.c
|
|
@@ -10,7 +10,6 @@
|
|
* See the Mulan PSL v2 for more details.
|
|
*/
|
|
|
|
-#define _GNU_SOURCE
|
|
#include <dlfcn.h>
|
|
#include <netdb.h>
|
|
#include <ifaddrs.h>
|
|
@@ -31,7 +30,7 @@
|
|
#include "lstack_log.h"
|
|
#include "lstack_cfg.h"
|
|
#include "lstack_lwip.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_preload.h"
|
|
|
|
#include "lstack_rtc_api.h"
|
|
diff --git a/src/lstack/core/dir.mk b/src/lstack/core/dir.mk
|
|
deleted file mode 100644
|
|
index 21b0d22..0000000
|
|
--- a/src/lstack/core/dir.mk
|
|
+++ /dev/null
|
|
@@ -1,13 +0,0 @@
|
|
-# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
|
-# gazelle is licensed under the Mulan PSL v2.
|
|
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
-# You may obtain a copy of Mulan PSL v2 at:
|
|
-# http://license.coscl.org.cn/MulanPSL2
|
|
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
-# PURPOSE.
|
|
-# See the Mulan PSL v2 for more details.
|
|
-
|
|
-SRC = lstack_preload.c lstack_init.c lstack_cfg.c lstack_dpdk.c lstack_control_plane.c lstack_stack_stat.c lstack_lwip.c lstack_protocol_stack.c lstack_thread_rpc.c lstack_virtio.c lstack_port_map.c
|
|
-$(eval $(call register_dir, core, $(SRC)))
|
|
-
|
|
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
|
|
index a165cdb..4bc4217 100644
|
|
--- a/src/lstack/core/lstack_cfg.c
|
|
+++ b/src/lstack/core/lstack_cfg.c
|
|
@@ -10,7 +10,6 @@
|
|
* See the Mulan PSL v2 for more details.
|
|
*/
|
|
|
|
-#define _GNU_SOURCE
|
|
#include <stdlib.h>
|
|
#include <getopt.h>
|
|
#include <stdio.h>
|
|
@@ -29,9 +28,9 @@
|
|
#include <lwip/posix_api.h>
|
|
#include <lwip/inet.h>
|
|
|
|
-#include "gazelle_reg_msg.h"
|
|
+#include "common/gazelle_reg_msg.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_log.h"
|
|
-#include "gazelle_base_func.h"
|
|
#include "lstack_cfg.h"
|
|
|
|
#define DEFAULT_CONF_FILE "/etc/gazelle/lstack.conf"
|
|
diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c
|
|
index 04858c7..4ab12f6 100644
|
|
--- a/src/lstack/core/lstack_control_plane.c
|
|
+++ b/src/lstack/core/lstack_control_plane.c
|
|
@@ -26,8 +26,8 @@
|
|
|
|
#include "lstack_cfg.h"
|
|
#include "lstack_dpdk.h"
|
|
-#include "gazelle_reg_msg.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_reg_msg.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_stack_stat.h"
|
|
#include "lstack_log.h"
|
|
#include "lstack_thread_rpc.h"
|
|
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
|
|
index 2de41e3..583bb09 100644
|
|
--- a/src/lstack/core/lstack_dpdk.c
|
|
+++ b/src/lstack/core/lstack_dpdk.c
|
|
@@ -10,7 +10,6 @@
|
|
* See the Mulan PSL v2 for more details.
|
|
*/
|
|
|
|
-#define _GNU_SOURCE
|
|
#include <sched.h>
|
|
#include <stdbool.h>
|
|
#include <securec.h>
|
|
@@ -44,7 +43,7 @@
|
|
#include <rte_ethdev.h>
|
|
|
|
#include "lstack_log.h"
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "lstack_protocol_stack.h"
|
|
#include "lstack_thread_rpc.h"
|
|
#include "lstack_lwip.h"
|
|
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
|
|
index c2499d7..d97b218 100644
|
|
--- a/src/lstack/core/lstack_init.c
|
|
+++ b/src/lstack/core/lstack_init.c
|
|
@@ -10,7 +10,6 @@
|
|
* See the Mulan PSL v2 for more details.
|
|
*/
|
|
|
|
-#define _GNU_SOURCE
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
@@ -41,10 +40,10 @@
|
|
#include "lstack_dpdk.h"
|
|
#include "lstack_stack_stat.h"
|
|
#include "lstack_log.h"
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "posix/lstack_epoll.h"
|
|
#include "posix/lstack_unistd.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_protocol_stack.h"
|
|
#include "lstack_preload.h"
|
|
#include "lstack_wrap.h"
|
|
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
|
index 3728100..6e50e4d 100644
|
|
--- a/src/lstack/core/lstack_lwip.c
|
|
+++ b/src/lstack/core/lstack_lwip.c
|
|
@@ -27,7 +27,7 @@
|
|
#include <rte_errno.h>
|
|
#include <rte_malloc.h>
|
|
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_ethdev.h"
|
|
#include "lstack_protocol_stack.h"
|
|
#include "lstack_log.h"
|
|
@@ -35,7 +35,7 @@
|
|
#include "lstack_stack_stat.h"
|
|
#include "posix/lstack_epoll.h"
|
|
#include "lstack_thread_rpc.h"
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "lstack_cfg.h"
|
|
#include "lstack_lwip.h"
|
|
|
|
diff --git a/src/lstack/core/lstack_preload.c b/src/lstack/core/lstack_preload.c
|
|
index 1d68501..f7caef5 100644
|
|
--- a/src/lstack/core/lstack_preload.c
|
|
+++ b/src/lstack/core/lstack_preload.c
|
|
@@ -12,7 +12,6 @@
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
-#define __USE_GNU
|
|
#include <pthread.h>
|
|
#include <securec.h>
|
|
|
|
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
|
|
index e272a04..1983c0b 100644
|
|
--- a/src/lstack/core/lstack_protocol_stack.c
|
|
+++ b/src/lstack/core/lstack_protocol_stack.c
|
|
@@ -9,7 +9,7 @@
|
|
* PURPOSE.
|
|
* See the Mulan PSL v2 for more details.
|
|
*/
|
|
-#define _GNU_SOURCE
|
|
+
|
|
#include <pthread.h>
|
|
#include <stdatomic.h>
|
|
|
|
@@ -22,9 +22,9 @@
|
|
#include <securec.h>
|
|
#include <numa.h>
|
|
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "lstack_thread_rpc.h"
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "lstack_log.h"
|
|
#include "lstack_dpdk.h"
|
|
#include "lstack_ethdev.h"
|
|
diff --git a/src/lstack/core/lstack_stack_stat.c b/src/lstack/core/lstack_stack_stat.c
|
|
index 1e32c45..423be81 100644
|
|
--- a/src/lstack/core/lstack_stack_stat.c
|
|
+++ b/src/lstack/core/lstack_stack_stat.c
|
|
@@ -22,8 +22,8 @@
|
|
#include "posix_api.h"
|
|
#include "lstack_control_plane.h"
|
|
#include "lstack_log.h"
|
|
-#include "dpdk_common.h"
|
|
-#include "gazelle_dfx_msg.h"
|
|
+#include "common/dpdk_common.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
#include "lstack_thread_rpc.h"
|
|
#include "lstack_protocol_stack.h"
|
|
#include "posix/lstack_epoll.h"
|
|
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
|
|
index a15088a..4fc99f3 100644
|
|
--- a/src/lstack/include/lstack_cfg.h
|
|
+++ b/src/lstack/include/lstack_cfg.h
|
|
@@ -20,7 +20,7 @@
|
|
#include <rte_bus_pci.h>
|
|
|
|
#include "lstack_protocol_stack.h"
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
#define BASE_BIN_SCALE 2
|
|
#define BASE_OCT_SCALE 8
|
|
diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h
|
|
index dff1e44..91af3c5 100644
|
|
--- a/src/lstack/include/lstack_dpdk.h
|
|
+++ b/src/lstack/include/lstack_dpdk.h
|
|
@@ -14,8 +14,8 @@
|
|
#define _GAZELLE_DPDK_H_
|
|
|
|
#include <lwip/reg_sock.h>
|
|
-#include "gazelle_opt.h"
|
|
-#include "gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_opt.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
|
|
#define RXTX_CACHE_SZ (VDEV_RX_QUEUE_SZ)
|
|
|
|
diff --git a/src/lstack/include/lstack_fault_inject.h b/src/lstack/include/lstack_fault_inject.h
|
|
index afd8faf..a65c61f 100644
|
|
--- a/src/lstack/include/lstack_fault_inject.h
|
|
+++ b/src/lstack/include/lstack_fault_inject.h
|
|
@@ -15,6 +15,8 @@
|
|
|
|
#include <stdbool.h>
|
|
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
+
|
|
int32_t handle_fault_inject_cmd(int32_t sockfd, struct gazelle_fault_inject_data inject, enum GAZELLE_STAT_MODE stat_mode);
|
|
|
|
#endif /* __GAZELLE_INJECT_H__ */
|
|
diff --git a/src/lstack/include/lstack_lwip.h b/src/lstack/include/lstack_lwip.h
|
|
index 85c9c20..0b952ec 100644
|
|
--- a/src/lstack/include/lstack_lwip.h
|
|
+++ b/src/lstack/include/lstack_lwip.h
|
|
@@ -14,7 +14,7 @@
|
|
#define __GAZELLE_LWIP_H__
|
|
#include <stdbool.h>
|
|
|
|
-#include "gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
|
|
#define NETCONN_IS_ACCEPTIN(sock) (((sock)->conn->acceptmbox != NULL) && !sys_mbox_empty((sock)->conn->acceptmbox))
|
|
#define NETCONN_IS_DATAIN(sock) ((gazelle_ring_readable_count((sock)->recv_ring) || (sock)->recv_lastdata) || (sock->same_node_rx_ring != NULL && same_node_ring_count(sock)))
|
|
diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h
|
|
index 6ca4f14..5b04c6d 100644
|
|
--- a/src/lstack/include/lstack_protocol_stack.h
|
|
+++ b/src/lstack/include/lstack_protocol_stack.h
|
|
@@ -20,11 +20,11 @@
|
|
#include <lwip/list.h>
|
|
#include <lwip/netif.h>
|
|
|
|
-#include "gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_opt.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
#include "lstack_thread_rpc.h"
|
|
#include "lstack_ethdev.h"
|
|
#include "lstack_tx_cache.h"
|
|
-#include "gazelle_opt.h"
|
|
|
|
#define SOCK_RECV_RING_SIZE (get_global_cfg_params()->recv_ring_size)
|
|
#define SOCK_RECV_FREE_THRES (32)
|
|
diff --git a/src/lstack/include/posix/lstack_epoll.h b/src/lstack/include/posix/lstack_epoll.h
|
|
index a7164f4..77b6ebb 100644
|
|
--- a/src/lstack/include/posix/lstack_epoll.h
|
|
+++ b/src/lstack/include/posix/lstack_epoll.h
|
|
@@ -20,8 +20,8 @@
|
|
|
|
#include <lwip/list.h>
|
|
|
|
-#include "gazelle_dfx_msg.h"
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
diff --git a/src/lstack/netif/dir.mk b/src/lstack/netif/dir.mk
|
|
deleted file mode 100644
|
|
index b551041..0000000
|
|
--- a/src/lstack/netif/dir.mk
|
|
+++ /dev/null
|
|
@@ -1,15 +0,0 @@
|
|
-# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
|
-# gazelle is licensed under the Mulan PSL v2.
|
|
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
-# You may obtain a copy of Mulan PSL v2 at:
|
|
-# http://license.coscl.org.cn/MulanPSL2
|
|
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
-# PURPOSE.
|
|
-# See the Mulan PSL v2 for more details.
|
|
-
|
|
-SRC = lstack_ethdev.c lstack_vdev.c lstack_flow.c lstack_tx_cache.c
|
|
-ifeq ($(GAZELLE_FAULT_INJECT_ENABLE), 1)
|
|
- SRC += lstack_fault_inject.c
|
|
-endif
|
|
-$(eval $(call register_dir, netif, $(SRC)))
|
|
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
|
|
index 933c3e8..e23d313 100644
|
|
--- a/src/lstack/netif/lstack_ethdev.c
|
|
+++ b/src/lstack/netif/lstack_ethdev.c
|
|
@@ -24,7 +24,7 @@
|
|
|
|
#include <securec.h>
|
|
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "lstack_cfg.h"
|
|
#include "lstack_vdev.h"
|
|
#include "lstack_stack_stat.h"
|
|
diff --git a/src/lstack/netif/lstack_fault_inject.c b/src/lstack/netif/lstack_fault_inject.c
|
|
index 4edc6cc..4736e29 100644
|
|
--- a/src/lstack/netif/lstack_fault_inject.c
|
|
+++ b/src/lstack/netif/lstack_fault_inject.c
|
|
@@ -20,6 +20,9 @@
|
|
#include "lstack_log.h"
|
|
#include "lstack_vdev.h"
|
|
|
|
+#ifdef GAZELLE_FAULT_INJECT_ENABLE
|
|
+#include "lstack_fault_inject.h"
|
|
+
|
|
#define INJECT_MODULO 1000 /* used in modulus operator */
|
|
#define INJECT_US_TO_MS 1000 /* transefer time unit us to ms */
|
|
|
|
@@ -371,3 +374,4 @@ int32_t handle_fault_inject_cmd(int32_t sockfd, struct gazelle_fault_inject_data
|
|
return inject_set_cmd(sockfd, inject);
|
|
}
|
|
|
|
+#endif /* GAZELLE_FAULT_INJECT_ENABLE */
|
|
diff --git a/src/lstack/netif/lstack_flow.c b/src/lstack/netif/lstack_flow.c
|
|
index 9e8792c..84497dc 100644
|
|
--- a/src/lstack/netif/lstack_flow.c
|
|
+++ b/src/lstack/netif/lstack_flow.c
|
|
@@ -22,7 +22,7 @@
|
|
#include <lwip/tcp.h>
|
|
#include <lwip/prot/tcp.h>
|
|
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "lstack_log.h"
|
|
#include "lstack_dpdk.h"
|
|
#include "lstack_cfg.h"
|
|
diff --git a/src/lstack/netif/lstack_tx_cache.c b/src/lstack/netif/lstack_tx_cache.c
|
|
index ac5a9db..cda0003 100644
|
|
--- a/src/lstack/netif/lstack_tx_cache.c
|
|
+++ b/src/lstack/netif/lstack_tx_cache.c
|
|
@@ -15,7 +15,7 @@
|
|
#include "lwip/sockets.h"
|
|
#include "lstack_ethdev.h"
|
|
#include "lstack_log.h"
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
#include "lstack_protocol_stack.h"
|
|
#include "lstack_tx_cache.h"
|
|
|
|
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
|
|
index 75e4acc..63f9e40 100644
|
|
--- a/src/lstack/netif/lstack_vdev.c
|
|
+++ b/src/lstack/netif/lstack_vdev.c
|
|
@@ -29,9 +29,9 @@
|
|
#include "lstack_ethdev.h"
|
|
#include "lstack_control_plane.h"
|
|
#include "lstack_log.h"
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "lstack_protocol_stack.h"
|
|
-#include "gazelle_reg_msg.h"
|
|
+#include "common/gazelle_reg_msg.h"
|
|
#include "lstack_lwip.h"
|
|
#include "lstack_flow.h"
|
|
#include "lstack_vdev.h"
|
|
diff --git a/src/ltran/CMakeLists.txt b/src/ltran/CMakeLists.txt
|
|
index fee3a94..8e9b1ea 100644
|
|
--- a/src/ltran/CMakeLists.txt
|
|
+++ b/src/ltran/CMakeLists.txt
|
|
@@ -12,25 +12,7 @@ cmake_minimum_required(VERSION 3.12.1)
|
|
project(ltran)
|
|
|
|
set(COMMON_DIR ${PROJECT_SOURCE_DIR}/../common)
|
|
-set(LWIP_DIR /usr/include/lwip)
|
|
-
|
|
-set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
-if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
- set(CMAKE_C_FLAGS "-g -fstack-protector-strong -Wall -Werror -fPIE -pie -pthread -D_FORTIFY_SOURCE=2 -O2 -fPIC")
|
|
-elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
- set(CMAKE_C_FLAGS "-O2 -g -fstack-protector-strong -Wall -Werror -fPIE -pthread")
|
|
-endif()
|
|
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D LTRAN_COMPILE")
|
|
-
|
|
-if($ENV{GAZELLE_COVERAGE_ENABLE})
|
|
- message("Enable Coverage compile option")
|
|
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs")
|
|
-endif($ENV{GAZELLE_COVERAGE_ENABLE})
|
|
-
|
|
-if($ENV{GAZELLE_FAULT_INJECT_ENABLE})
|
|
- message("Enable Fault inject option")
|
|
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGAZELLE_FAULT_INJECT_ENABLE")
|
|
-endif($ENV{GAZELLE_FAULT_INJECT_ENABLE})
|
|
+set(LWIP_INCLUDE_DIR /usr/include/lwip)
|
|
|
|
execute_process(
|
|
COMMAND rpm -qa dpdk
|
|
@@ -40,62 +22,99 @@ execute_process(
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+" DPDK_VERSION ${DPDK_VERSION_FULL})
|
|
|
|
if (DPDK_VERSION STREQUAL "21.11")
|
|
- set(DPDK_DIR /usr/local/include/)
|
|
+ set(DPDK_INCLUDE_DIR /usr/local/include/)
|
|
else()
|
|
- set(DPDK_DIR /usr/include/dpdk)
|
|
+ set(DPDK_INCLUDE_DIR /usr/include/dpdk)
|
|
+endif()
|
|
+
|
|
+
|
|
+set(CMAKE_C_FLAGS "-O2 -g")
|
|
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLTRAN_COMPILE -D_GNU_SOURCE -fno-strict-aliasing")
|
|
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -fstack-protector-strong -fPIE")
|
|
+if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pie -D_FORTIFY_SOURCE=2 -fPIC")
|
|
+endif()
|
|
+
|
|
+# gcc coredump in openEuler-20.03-LTS-XX aarch64 when add -march=native
|
|
+if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64|aarch64|ppc64le|riscv64" )
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -Wcast-align")
|
|
endif()
|
|
|
|
+if($ENV{GAZELLE_COVERAGE_ENABLE})
|
|
+ message("Enable Coverage compile option")
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs")
|
|
+endif($ENV{GAZELLE_COVERAGE_ENABLE})
|
|
+
|
|
+if($ENV{GAZELLE_FAULT_INJECT_ENABLE})
|
|
+ message("Enable Fault inject option")
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGAZELLE_FAULT_INJECT_ENABLE")
|
|
+endif($ENV{GAZELLE_FAULT_INJECT_ENABLE})
|
|
+
|
|
+set(LTRAN_C_FLAGS -D__ARM_FEATURE_CRC32=1
|
|
+ -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition
|
|
+ -Wpointer-arith -Wcast-qual -Wnested-externs -Wformat-nonliteral -Wformat-security -Wundef
|
|
+ -Wdeprecated -Wwrite-strings -Wno-implicit-fallthrough -Wno-error=deprecated-declarations)
|
|
+
|
|
+set(DPDK_C_FLAGS -DRTE_MACHINE_CPUFLAG_NEON -DRTE_MACHINE_CPUFLAG_CRC32
|
|
+ -DRTE_MACHINE_CPUFLAG_PMULL -DRTE_MACHINE_CPUFLAG_AES
|
|
+ -DRTE_MACHINE_CPUFLAG_SHA1 -DRTE_MACHINE_CPUFLAG_SHA2
|
|
+ -include rte_config.h)
|
|
+
|
|
+set(DPDK_LINK_FLAGS -Wl,-lrte_meter -Wl,-lrte_gro -Wl,-lrte_hash -Wl,-lrte_kvargs
|
|
+ -Wl,-lrte_mbuf -Wl,-lrte_ethdev -Wl,-lrte_net -Wl,-lrte_timer -Wl,-lrte_mempool
|
|
+ -Wl,-lrte_mempool_ring -Wl,-lrte_ring -Wl,-lrte_pci -Wl,-lrte_cmdline
|
|
+ -Wl,-lrte_bus_pci -Wl,-lrte_bus_vdev -Wl,-lrte_pdump)
|
|
+
|
|
if (DPDK_VERSION STREQUAL "19.11")
|
|
- set(DPDK_LINK_FLAGS "-Wl,-lrte_pmd_bond -Wl,-lrte_pmd_hinic -Wl,-lrte_pmd_ixgbe \
|
|
- -Wl,-lrte_pmd_pcap -Wl,-lrte_pmd_virtio")
|
|
+ set(DPDK_LINK_FLAGS ${DPDK_LINK_FLAGS} -Wl,-lrte_pmd_bond -Wl,-lrte_pmd_hinic -Wl,-lrte_pmd_ixgbe
|
|
+ -Wl,-lrte_pmd_pcap -Wl,-lrte_pmd_virtio)
|
|
if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
|
- set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lrte_pmd_i40e")
|
|
+ set(DPDK_LINK_FLAGS ${DPDK_LINK_FLAGS} -Wl,-lrte_pmd_i40e)
|
|
endif()
|
|
else()
|
|
- set(DPDK_LINK_FLAGS "-Wl,-lrte_net_bond -Wl,-lrte_net_hinic -Wl,-lrte_net_ixgbe \
|
|
- -Wl,-lpcap -Wl,-lrte_net_pcap -Wl,-lrte_net_virtio -Wl,-lrte_pcapng -Wl,-lrte_telemetry")
|
|
+ set(DPDK_LINK_FLAGS ${DPDK_LINK_FLAGS} -Wl,-lrte_net_bond -Wl,-lrte_net_hinic -Wl,-lrte_net_ixgbe
|
|
+ -Wl,-lpcap -Wl,-lrte_net_pcap -Wl,-lrte_net_virtio -Wl,-lrte_pcapng -Wl,-lrte_telemetry)
|
|
if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64|riscv64")
|
|
- set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lrte_net_i40e")
|
|
+ set(DPDK_LINK_FLAGS ${DPDK_LINK_FLAGS} -Wl,-lrte_net_i40e)
|
|
endif()
|
|
endif()
|
|
|
|
if (DPDK_VERSION GREATER_EQUAL 23.11)
|
|
- set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -lrte_log -larchive -Wl,-lrte_eal")
|
|
+ set(DPDK_LINK_FLAGS ${DPDK_LINK_FLAGS} -lrte_log -larchive -Wl,-lrte_eal)
|
|
else()
|
|
- set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -lrte_kni -Wl,-Bstatic -lrte_eal -Wl,-Bdynamic")
|
|
+ set(DPDK_LINK_FLAGS ${DPDK_LINK_FLAGS} -lrte_kni -Wl,-Bstatic -Wl,-lrte_eal -Wl,-Bdynamic)
|
|
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ppc64le")
|
|
- set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-larchive")
|
|
+ set(DPDK_LINK_FLAGS ${DPDK_LINK_FLAGS} -Wl,-larchive)
|
|
endif()
|
|
endif()
|
|
|
|
+# compile info
|
|
+# set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
+message("[CMAKE_C_FLAGS] ${CMAKE_C_FLAGS}")
|
|
+message("[LTRAN_C_FLAGS] ${LTRAN_C_FLAGS}")
|
|
+message("[DPDK_C_FLAGS ] ${DPDK_C_FLAGS}")
|
|
+message("[DPDK_LINK_FLAGS] ${DPDK_LINK_FLAGS}")
|
|
+
|
|
add_executable(ltran main.c ltran_param.c ltran_config.c ltran_ethdev.c ltran_stat.c ltran_errno.c
|
|
- ltran_monitor.c ltran_instance.c ltran_stack.c ltran_tcp_conn.c ltran_tcp_sock.c
|
|
- ltran_forward.c ltran_timer.c ${COMMON_DIR}/gazelle_dfx_msg.c ${COMMON_DIR}/dpdk_common.c
|
|
- ${COMMON_DIR}/gazelle_parse_config.c)
|
|
-
|
|
-target_include_directories(ltran PRIVATE ${COMMON_DIR} ${PROJECT_SOURCE_DIR} ${LWIP_DIR} ${DPDK_DIR})
|
|
-target_compile_options(ltran PRIVATE -fno-strict-aliasing -D__ARM_FEATURE_CRC32=1 -DRTE_MACHINE_CPUFLAG_NEON
|
|
- -DRTE_MACHINE_CPUFLAG_CRC32 -DRTE_MACHINE_CPUFLAG_PMULL -DRTE_MACHINE_CPUFLAG_AES
|
|
- -DRTE_MACHINE_CPUFLAG_SHA1 -DRTE_MACHINE_CPUFLAG_SHA2 -include rte_config.h
|
|
- -D_GNU_SOURCE -W -Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition
|
|
- -Wpointer-arith -Wcast-qual -Wnested-externs -Wformat-nonliteral -Wformat-security -Wundef
|
|
- -Wdeprecated -Wwrite-strings -Wno-implicit-fallthrough -D_FORTIFY_SOURCE=2 -Wno-error=deprecated-declarations)
|
|
+ ltran_monitor.c ltran_instance.c ltran_stack.c ltran_tcp_conn.c ltran_tcp_sock.c
|
|
+ ltran_forward.c ltran_timer.c
|
|
+ ${COMMON_DIR}/gazelle_dfx_msg.c
|
|
+ ${COMMON_DIR}/dpdk_common.c
|
|
+ ${COMMON_DIR}/gazelle_parse_config.c)
|
|
|
|
-# gcc coredump in openEuler-20.03-LTS-XX aarch64 when add -march=native
|
|
-if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64|aarch64|ppc64le|riscv64" )
|
|
- target_compile_options(ltran PRIVATE -march=native -Wcast-align)
|
|
-endif()
|
|
+target_include_directories(ltran PRIVATE ${COMMON_DIR}/../ ${PROJECT_SOURCE_DIR} ${LWIP_INCLUDE_DIR} ${DPDK_INCLUDE_DIR})
|
|
|
|
-target_link_libraries(ltran PRIVATE config boundscheck rte_pdump -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines)
|
|
+# COMPILE_FLAGS and LINK_FLAGS are deprecated.
|
|
+target_compile_options(ltran PRIVATE ${LTRAN_C_FLAGS} ${DPDK_C_FLAGS})
|
|
+target_link_options(ltran PRIVATE
|
|
+ -Wl,--whole-archive ${DPDK_LINK_FLAGS} -Wl,--no-whole-archive
|
|
+ -Wl,--as-needed -Wl,-export-dynamic
|
|
+ -Wl,-Map=ltran.map -Wl,--cref)
|
|
+target_link_libraries(ltran PRIVATE pthread config boundscheck
|
|
+ -Wl,-lm -Wl,-lrt -Wl,-lnuma -Wl,-ldl
|
|
+ -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines)
|
|
|
|
-set_target_properties(ltran PROPERTIES LINK_FLAGS "-L$ENV{DPDK_LIB_PATH} -Wl,--no-whole-archive \
|
|
- -Wl,-lrte_meter -Wl,--whole-archive -Wl,-lrte_gro -Wl,-lrte_hash -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_ethdev \
|
|
- -Wl,-lrte_net -Wl,-lrte_timer -Wl,-lrte_mempool -Wl,-lrte_mempool_ring -Wl,-lrte_ring -Wl,-lrte_pci \
|
|
- -Wl,-lrte_cmdline -Wl,-lrte_bus_pci\
|
|
- -Wl,-lrte_bus_vdev ${DPDK_LINK_FLAGS} \
|
|
- -Wl,--no-whole-archive -Wl,-lm -Wl,-lrt -Wl,-lnuma -Wl,-ldl -Wl,-export-dynamic -Wl,-export-dynamic \
|
|
- -Wl,--as-needed -Wl,-export-dynamic -Wl,-Map=ltran.map -Wl,--cref")
|
|
|
|
add_executable(gazellectl ltran_dfx.c ${COMMON_DIR}/gazelle_dfx_msg.c)
|
|
-target_include_directories(gazellectl PRIVATE $ENV{DPDK_INCLUDE_FILE} ${COMMON_DIR} ${DPDK_DIR})
|
|
+target_include_directories(gazellectl PRIVATE ${COMMON_DIR}/../ ${DPDK_INCLUDE_DIR})
|
|
target_link_libraries(gazellectl PRIVATE boundscheck -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack)
|
|
diff --git a/src/ltran/ltran_base.h b/src/ltran/ltran_base.h
|
|
index f174a40..9462fe5 100644
|
|
--- a/src/ltran/ltran_base.h
|
|
+++ b/src/ltran/ltran_base.h
|
|
@@ -15,7 +15,7 @@
|
|
|
|
#include <limits.h>
|
|
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
#define GAZELLE_CMD_BUFFER_SIZE _POSIX_ARG_MAX
|
|
#define GAZELLE_PATH_BUFFER_SIZE PATH_MAX
|
|
diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c
|
|
index cdcd7b3..005b09c 100644
|
|
--- a/src/ltran/ltran_dfx.c
|
|
+++ b/src/ltran/ltran_dfx.c
|
|
@@ -30,7 +30,7 @@
|
|
|
|
#include "ltran_stat.h"
|
|
#include "ltran_base.h"
|
|
-#include "gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
|
|
/* seeing show_usage() */
|
|
#define GAZELLE_TARGET_ARG_IDX 1
|
|
diff --git a/src/ltran/ltran_ethdev.c b/src/ltran/ltran_ethdev.c
|
|
index 2f08d4a..68dc786 100644
|
|
--- a/src/ltran/ltran_ethdev.c
|
|
+++ b/src/ltran/ltran_ethdev.c
|
|
@@ -30,13 +30,13 @@
|
|
|
|
#include <lwip/dpdk_version.h>
|
|
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "ltran_param.h"
|
|
#include "ltran_log.h"
|
|
#include "ltran_base.h"
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
#include "ltran_errno.h"
|
|
-#include "gazelle_reg_msg.h"
|
|
+#include "common/gazelle_reg_msg.h"
|
|
|
|
uint32_t g_bond_num = 0;
|
|
FILE* g_log_file = NULL;
|
|
diff --git a/src/ltran/ltran_ethdev.h b/src/ltran/ltran_ethdev.h
|
|
index f720c55..b84baae 100644
|
|
--- a/src/ltran/ltran_ethdev.h
|
|
+++ b/src/ltran/ltran_ethdev.h
|
|
@@ -15,7 +15,7 @@
|
|
|
|
#include <stdint.h>
|
|
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
struct port_info {
|
|
uint16_t num_ports;
|
|
diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c
|
|
index c49da89..c2f53d6 100644
|
|
--- a/src/ltran/ltran_forward.c
|
|
+++ b/src/ltran/ltran_forward.c
|
|
@@ -28,7 +28,7 @@
|
|
#include <rte_ring.h>
|
|
#include <securec.h>
|
|
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "ltran_instance.h"
|
|
#include "ltran_tcp_conn.h"
|
|
#include "ltran_tcp_sock.h"
|
|
diff --git a/src/ltran/ltran_instance.c b/src/ltran/ltran_instance.c
|
|
index fc5b0fb..428c1aa 100644
|
|
--- a/src/ltran/ltran_instance.c
|
|
+++ b/src/ltran/ltran_instance.c
|
|
@@ -25,10 +25,10 @@
|
|
#include "ltran_stat.h"
|
|
#include "ltran_log.h"
|
|
#include "ltran_base.h"
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
#include "ltran_errno.h"
|
|
-#include "gazelle_dfx_msg.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "ltran_instance.h"
|
|
|
|
volatile unsigned long g_tx_loop_count __rte_cache_aligned;
|
|
diff --git a/src/ltran/ltran_instance.h b/src/ltran/ltran_instance.h
|
|
index 2b888ec..f0fe580 100644
|
|
--- a/src/ltran/ltran_instance.h
|
|
+++ b/src/ltran/ltran_instance.h
|
|
@@ -17,8 +17,8 @@
|
|
#include <netinet/in.h>
|
|
#include <limits.h>
|
|
|
|
-#include "gazelle_opt.h"
|
|
-#include "gazelle_reg_msg.h"
|
|
+#include "common/gazelle_opt.h"
|
|
+#include "common/gazelle_reg_msg.h"
|
|
|
|
struct gazelle_stack;
|
|
struct gazelle_instance {
|
|
diff --git a/src/ltran/ltran_monitor.c b/src/ltran/ltran_monitor.c
|
|
index 457e8c8..93ab2d5 100644
|
|
--- a/src/ltran/ltran_monitor.c
|
|
+++ b/src/ltran/ltran_monitor.c
|
|
@@ -29,8 +29,8 @@
|
|
#include "ltran_log.h"
|
|
#include "ltran_stat.h"
|
|
#include "ltran_instance.h"
|
|
-#include "gazelle_dfx_msg.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "ltran_param.h"
|
|
#include "ltran_monitor.h"
|
|
|
|
diff --git a/src/ltran/ltran_param.c b/src/ltran/ltran_param.c
|
|
index bd5a8e1..ad689f6 100644
|
|
--- a/src/ltran/ltran_param.c
|
|
+++ b/src/ltran/ltran_param.c
|
|
@@ -23,8 +23,8 @@
|
|
#include "ltran_errno.h"
|
|
#include "ltran_base.h"
|
|
#include "ltran_log.h"
|
|
-#include "gazelle_dfx_msg.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "ltran_param.h"
|
|
|
|
#define HEX_BASE 16
|
|
diff --git a/src/ltran/ltran_param.h b/src/ltran/ltran_param.h
|
|
index 75addcd..e48b781 100644
|
|
--- a/src/ltran/ltran_param.h
|
|
+++ b/src/ltran/ltran_param.h
|
|
@@ -17,7 +17,7 @@
|
|
#include <netinet/in.h>
|
|
#include <rte_ether.h>
|
|
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
struct ltran_config {
|
|
struct {
|
|
diff --git a/src/ltran/ltran_stack.c b/src/ltran/ltran_stack.c
|
|
index 2aed6c9..299fb7a 100644
|
|
--- a/src/ltran/ltran_stack.c
|
|
+++ b/src/ltran/ltran_stack.c
|
|
@@ -16,7 +16,7 @@
|
|
#include "ltran_instance.h"
|
|
#include "ltran_log.h"
|
|
#include "ltran_jhash.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "ltran_stack.h"
|
|
|
|
struct gazelle_stack_htable *g_stack_htable = NULL;
|
|
diff --git a/src/ltran/ltran_stat.c b/src/ltran/ltran_stat.c
|
|
index dfd5fc9..0a8d75c 100644
|
|
--- a/src/ltran/ltran_stat.c
|
|
+++ b/src/ltran/ltran_stat.c
|
|
@@ -21,12 +21,12 @@
|
|
#include "ltran_tcp_conn.h"
|
|
#include "ltran_instance.h"
|
|
#include "ltran_log.h"
|
|
-#include "gazelle_dfx_msg.h"
|
|
+#include "common/gazelle_dfx_msg.h"
|
|
#include "ltran_timer.h"
|
|
#include "ltran_ethdev.h"
|
|
#include "ltran_base.h"
|
|
#include "ltran_stack.h"
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "ltran_forward.h"
|
|
|
|
/* undefine lwip_ntohs in lwip/def.h */
|
|
diff --git a/src/ltran/ltran_stat.h b/src/ltran/ltran_stat.h
|
|
index 16d03a1..75cb353 100644
|
|
--- a/src/ltran/ltran_stat.h
|
|
+++ b/src/ltran/ltran_stat.h
|
|
@@ -17,7 +17,7 @@
|
|
|
|
#include <rte_common.h>
|
|
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
/*
|
|
* When doing reads from the NIC or the client queues,
|
|
diff --git a/src/ltran/ltran_tcp_conn.h b/src/ltran/ltran_tcp_conn.h
|
|
index fa508bc..82c5faf 100644
|
|
--- a/src/ltran/ltran_tcp_conn.h
|
|
+++ b/src/ltran/ltran_tcp_conn.h
|
|
@@ -18,7 +18,7 @@
|
|
#include <stdbool.h>
|
|
#include <lwip/reg_sock.h>
|
|
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
struct gazelle_tcp_conn {
|
|
uint32_t tid;
|
|
diff --git a/src/ltran/ltran_tcp_sock.c b/src/ltran/ltran_tcp_sock.c
|
|
index 940ded8..4044fc0 100644
|
|
--- a/src/ltran/ltran_tcp_sock.c
|
|
+++ b/src/ltran/ltran_tcp_sock.c
|
|
@@ -18,7 +18,7 @@
|
|
#include "ltran_instance.h"
|
|
#include "ltran_base.h"
|
|
#include "ltran_jhash.h"
|
|
-#include "gazelle_base_func.h"
|
|
+#include "common/gazelle_base_func.h"
|
|
#include "ltran_tcp_sock.h"
|
|
|
|
struct gazelle_tcp_sock_htable *g_tcp_sock_htable = NULL;
|
|
diff --git a/src/ltran/ltran_tcp_sock.h b/src/ltran/ltran_tcp_sock.h
|
|
index a6e9571..e40891d 100644
|
|
--- a/src/ltran/ltran_tcp_sock.h
|
|
+++ b/src/ltran/ltran_tcp_sock.h
|
|
@@ -17,7 +17,7 @@
|
|
#include <pthread.h>
|
|
#include <stdint.h>
|
|
|
|
-#include "gazelle_opt.h"
|
|
+#include "common/gazelle_opt.h"
|
|
|
|
struct gazelle_stack;
|
|
struct gazelle_tcp_sock {
|
|
diff --git a/src/ltran/main.c b/src/ltran/main.c
|
|
index 6cc8bc9..3d2310b 100644
|
|
--- a/src/ltran/main.c
|
|
+++ b/src/ltran/main.c
|
|
@@ -20,7 +20,7 @@
|
|
#include <rte_eal.h>
|
|
#include <rte_version.h>
|
|
|
|
-#include "dpdk_common.h"
|
|
+#include "common/dpdk_common.h"
|
|
#include "ltran_log.h"
|
|
#include "ltran_param.h"
|
|
#include "ltran_stat.h"
|
|
--
|
|
2.33.0
|
|
|