diff options
-rw-r--r-- | CMakeLists.txt | 38 | ||||
-rw-r--r-- | doc/Build_DMM.md | 102 | ||||
-rwxr-xr-x | scripts/build_dpdk1802.sh | 8 | ||||
-rwxr-xr-x | scripts/git/commit-msg-hook.py | 2 | ||||
-rwxr-xr-x | scripts/git/pre-commit | 14 | ||||
-rw-r--r-- | thirdparty/apps/CMakeLists.txt | 5 |
6 files changed, 110 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index adb0670..e63100f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) PROJECT(nStack) + +option(RMWS "automatically remove trailing whitespace using git pre-commit hook" OFF) +option(WITH_SECUREC_LIB "Option description" OFF) +option(WITH_HAL_LIB "Option description" OFF) + SET(CMAKE_C_COMPILER "gcc") SET(EXECUTABLE_PATH ${CMAKE_CURRENT_LIST_DIR}/release/bin) SET(LIB_PATH_STATIC ${PROJECT_BINARY_DIR}) @@ -51,14 +56,35 @@ if(commit_template STREQUAL "") message(STATUS "Setting git commit template...done") endif() -if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg") - message(STATUS "Setting git commit hook...") - execute_process(COMMAND ln -s ${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg) - message(STATUS "Setting git commit hook...done") +find_program(GIT_REVIEW git-review) +if(NOT GIT_REVIEW) + if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg") + message(STATUS "git-review not found!") + message(STATUS "Setting git commit hook...") + execute_process(COMMAND ln -s ${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg) + message(STATUS "Setting git commit hook...done") + endif() +else() + if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg") + execute_process(COMMAND git-review -s + RESULT_VARIABLE git_review_ret) + if(${git_review_ret} EQUAL 0) + file(APPEND ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg "${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py $1") + endif() + else() + file(READ ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg contents) + string(FIND "${contents}" "commit-msg-hook.py" match_ret) + if(${match_ret} EQUAL -1) + file(APPEND ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg "${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-hook.py $1") + endif() + endif() endif() -option(WITH_SECUREC_LIB "Option description" OFF) -option(WITH_HAL_LIB "Option description" OFF) +if(RMWS) + message(STATUS "Setting git pre-commit hook...") + execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/scripts/git/pre-commit ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit) + message(STATUS "Setting git pre-commit hook...done") +endif() if(WITH_SECUREC_LIB) add_definitions(-DSECUREC_LIB) diff --git a/doc/Build_DMM.md b/doc/Build_DMM.md index 58bd6b8..b74d5fb 100644 --- a/doc/Build_DMM.md +++ b/doc/Build_DMM.md @@ -1,105 +1,109 @@ -# 1. Introduction: +# 1. Introduction + The purpose of this document is to illustrate how to build DMM and run applications on it. Note: Users can easily build DMM by running DMM/scripts/build.sh, which contains following steps. -# 2. Build DPDK: +# 2. Build DPDK + DPDK needs to be built first for DMM RTE memory dependency. -- Steps : +- Steps: Download dpdk-18.02.tar.xz from DPDK release, you can get it from [http://static.dpdk.org/rel](http://static.dpdk.org/rel) -``` - #wget http://static.dpdk.org/rel/dpdk-18.02.tar.xz - #tar xvf dpdk-18.02.tar.xz - #vi dpdk-18.02/config/common_base + +```sh + wget http://static.dpdk.org/rel/dpdk-18.02.tar.xz + tar xvf dpdk-18.02.tar.xz + vi dpdk-18.02/config/common_base //make CONFIG_RTE_BUILD_SHARED_LIB=y, CONFIG_RTE_EXEC_ENV=y, CONFIG_RTE_LIBRTE_EAL=y, CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/" - #cd dpdk-18.02 - #make install T=x86_64-native-linuxapp-gcc DESTDIR=/usr -j 4 - #cd x86_64-native-linuxapp-gcc - #make //install the dpdk which will generate .so inside lib folder in the path. - #mkdir -p /tmp/dpdk/drivers/ - #cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/ + cd dpdk-18.02 + make install T=x86_64-native-linuxapp-gcc DESTDIR=/usr -j 4 + cd x86_64-native-linuxapp-gcc + make # install the dpdk which will generate .so inside lib folder in the path. + mkdir -p /tmp/dpdk/drivers/ + cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/ ``` Note: + Under certain kernel versions (e.g. v3.10.0 adopted by CentOS 7.5), compiling DPDK with default + configuration will encounter errors like below. + `error: unknown field 'ndo_change_mtu' specified in initializer .no_change_mtu = kni_net_change_mtu` + This is caused by `kni` compiling, disable `kni` in dpdk config file will figure it out. + Actually, we have tested ubuntu 14.04 ~ 16.04, CentOS 7.2, and they worked well. - Environment: - Linux ubuntu 16.04 or some distro which support dpdk-18.02 - -# 3. Build DMM: +# 3. Build DMM -``` - #cd $(DMM_DIR)/thirdparty/glog/glog-0.3.4/ && autoreconf -ivf - #cd $(DMM_DIR)/build - #cmake .. +```sh + cd $(DMM_DIR)/thirdparty/glog/glog-0.3.4/ && autoreconf -ivf + cd $(DMM_DIR)/build + cmake .. ``` Note: $(DMM_DIR) is the directory where dmm has been cloned. After cmake all the makefiles and dependent .sh files will be copied under build directory. +```sh + make -j 8 ``` - #make -j 8 -``` + Then we can get libnStackAPI.so For centos we can use the command 'make pkg-rpm' to generate the rpm package in release/rpm. -# 4. Build rsocket: +# 4. Build rsocket +```sh + cd $(DMM_DIR)/build + make dmm_rsocket ``` - #cd $(DMM_DIR)/build - #make dmm_rsocket -``` + Note: Make sure Mellanox OFED has been installed in your computer, or run the following command before compiling +```sh + cd $DMM_DIR/stacks/rsocket + #Take ubuntu16.04 as an example, the tgz file has the format MLNX_OFED_LINUX-<ver>-<OS label><CPU arch>.tgz + wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz + tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz + cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64 + ./mlnxofedinstall --force ``` - #cd $DMM_DIR/stacks/rsocket - //Take ubuntu16.04 as an example, the tgz file has the format MLNX_OFED_LINUX-<ver>-<OS label><CPU arch>.tgz - #wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz - #tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz - #cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64 - #./mlnxofedinstall --force -``` - -# 5. Env Setting: +# 5. Env Setting - Hugepage setting: -``` - #sudo sysctl -w vm.nr_hugepages=1024 +```sh + sudo sysctl -w vm.nr_hugepages=1024 ``` Check hugepage info - -``` - #cat /proc/meminfo +```sh + cat /proc/meminfo ``` - Mount hugepages: -``` - #sudo mkdir -p /mnt/nstackhuge/ - #sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/ - #sudo mkdir -p /var/run/ip_module +```sh + sudo mkdir -p /mnt/nstackhuge/ + sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/ + sudo mkdir -p /var/run/ip_module ``` - # 6. Biuld and Run the APP - Link the app with the lib **libnStackAPI.so** first, you can refer to app_example/perf-test - Enable detail log of nstack by setting env var -``` - #export LD_LIBRARY_PATH=/dmm/release/lib64 - #export NSTACK_LOG_ON=DBG +```sh + export LD_LIBRARY_PATH=/dmm/release/lib64 + export NSTACK_LOG_ON=DBG ``` - Copy and update the module_config.json, rd_config.json into the same folder of app diff --git a/scripts/build_dpdk1802.sh b/scripts/build_dpdk1802.sh index 01379d6..1ed84bb 100755 --- a/scripts/build_dpdk1802.sh +++ b/scripts/build_dpdk1802.sh @@ -17,7 +17,7 @@ echo "check whether dpdk installed" cur_directory=${PWD} -check_dpdk=$(rpm -qa | grep dpdk) +check_dpdk=$(rpm -qa | grep dpdk-devel) if [ -z "$check_dpdk" ]; then echo "system will install the dpdk" else @@ -56,6 +56,12 @@ sed -i '83a sed -i '\''s!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_ sed -i '84a sed -i '\''s!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1'\'' config/common_base' dpdk.spec sed -i '85a sed -i '\''s!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1'\'' config/common_base' dpdk.spec +#disable KNI mode by default +sed -i '93a sed -ri '\''s!CONFIG_RTE_LIBRARY_KNI=.*!CONFIG_RTE_LIBRARY_KNI=n!1'\'' %{target}/.config' dpdk.spec +sed -i '94a sed -ri '\''s!CONFIG_RTE_LIBRARY_PMD_KNI=.*!CONFIG_RTE_LIBRARY_PMD_KNI=n!1'\'' %{target}/.config' dpdk.spec +sed -i '95a sed -ri '\''s!CONFIG_RTE_KNI_KMOD=.*!CONFIG_RTE_KNI_KMOD=n!1'\'' %{target}/.config' dpdk.spec +sed -i '96a sed -ri '\''s!CONFIG_RTE_KNI_PREEMPT_DEFAULT=.*!CONFIG_RTE_KNI_PREEMPT_DEFAULT=n!1'\'' %{target}/.config' dpdk.spec + echo "build the dependence" #sudo yum-builddep -y dpdk.spec sudo yum install -y libpcap-devel python-sphinx inkscape diff --git a/scripts/git/commit-msg-hook.py b/scripts/git/commit-msg-hook.py index 719ff22..9c397ed 100755 --- a/scripts/git/commit-msg-hook.py +++ b/scripts/git/commit-msg-hook.py @@ -123,7 +123,7 @@ with open(sys.argv[1], 'r') as commit_msg: for line in contents: dup = line.lstrip() - if dup.startswith('#'): + if dup.startswith('#') or dup.startswith("Change-Id") or dup.startswith("Signed-of-by"): continue if subject is True: ret = check_subject(line) diff --git a/scripts/git/pre-commit b/scripts/git/pre-commit new file mode 100755 index 0000000..58cd14f --- /dev/null +++ b/scripts/git/pre-commit @@ -0,0 +1,14 @@ +#!/bin/bash + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# autoremove trailing whitespace +for file in `git diff-index --check --cached $against -- | sed '/^[-+]/d' | sed -r 's/:[0-9]+:.*//' | uniq` ; do + sed -i 's/[ \t]*$//g' $file +done diff --git a/thirdparty/apps/CMakeLists.txt b/thirdparty/apps/CMakeLists.txt index de58120..5a0daff 100644 --- a/thirdparty/apps/CMakeLists.txt +++ b/thirdparty/apps/CMakeLists.txt @@ -10,7 +10,7 @@ else() SET(NGINX_DOWNLOAD_CMD wget --no-check-certificate -O nginx-1.12.2.tar.gz ${NGINX_URL} && tar -xvf ${NGINX_DOWNLOAD_DIR}/nginx-1.12.2.tar.gz -C ${NGINX_DOWNLOAD_DIR}/nginx-1.12.2 --strip-components 1) endif() -INCLUDE(ExternalProject) +INCLUDE(ExternalProject) ExternalProject_Add( NGINX URL ${NGINX_URL} @@ -19,8 +19,9 @@ ExternalProject_Add( BUILD_IN_SOURCE 1 SOURCE_DIR ${NGINX_SRC} PATCH_COMMAND echo "./configure --with-ld-opt=\"-L${LIB_PATH_SHARED}/ -lnStackAPI -Wl,-rpath=${LIB_PATH_SHARED}\" --sbin-path=${NGINX_RELEASE}/nginx --conf-path=${NGINX_RELEASE}/nginx.conf --pid-path=${NGINX_RELEASE}/nginx.pid " > configure.sh + COMMAND sed -i -e "48,49 s/^/#/" ${CMAKE_CURRENT_LIST_DIR}/nginx/nginx-1.12.2/auto/os/linux CONFIGURE_COMMAND sh configure.sh - BUILD_COMMAND make + BUILD_COMMAND make INSTALL_COMMAND make install DEPENDS nStackAPI ) |