diff options
-rw-r--r-- | release/configure/module_config.json | 50 | ||||
-rwxr-xr-x | scripts/build.sh | 89 | ||||
-rw-r--r-- | scripts/build_dpdk.sh | 73 | ||||
-rw-r--r-- | src/framework/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/nSocket/CMakeLists.txt | 44 |
5 files changed, 183 insertions, 77 deletions
diff --git a/release/configure/module_config.json b/release/configure/module_config.json index c9bae26..6b171d8 100644 --- a/release/configure/module_config.json +++ b/release/configure/module_config.json @@ -1,27 +1,31 @@ { - "default_stack_name": "kernel", - "module_list": [ + "default_stack_name": "kernel", /*when rd can't be find maybe choose the defualt one*/ + "module_list": [ { - "stack_name": "kernel", - "function_name": "kernel_stack_register", - "libname": "./", - "loadtype": "static", - "deploytype": "1", - "maxfd": "1024", - "minfd": "0", - "priorty": "1", - "stackid": "0", - }, + "stack_name": "kernel", /*stack name*/ + "function_name": "kernel_stack_register", /*function name*/ + "libname": "./", /*library name, if loadtype is static, this maybe + null, else must give a library name*/ + "loadtype": "static", /*library load type: static or dynamic*/ + "deploytype": "1", /*deploy model type:model type1, model type2, + model type3. Indicating single or multi process + deployment. Used during shared memory initialization.*/ + "maxfd": "1024", /*the max fd supported*/ + "minfd": "0", /*the min fd supported*/ + "priorty": "1", /*priorty when executing, reserv*/ + "stackid": "0", /*stack id, this must be ordered and not be repeated*/ + }, { - "stack_name": "stackpool", - "function_name": "nstack_stack_register", - "libname": "libnstack.so", - "loadtype": "dynmic", - "deploytype": "3", - "maxfd": "1024", - "minfd": "0", - "priorty": "1", - "stackid": "1", - }, - ] + "stack_name": "stackx", /*this is not a real stack, just an example for multiple + stack configurations*/ + "function_name": "stackx_register", + "libname": "libstackx.so", + "loadtype": "dynmic", + "deploytype": "3", + "maxfd": "1024", + "minfd": "0", + "priorty": "1", + "stackid": "1", + }, + ] } diff --git a/scripts/build.sh b/scripts/build.sh index 594af7f..9da32dd 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,5 +1,4 @@ ######################################################################### -# # Copyright (c) 2018 Huawei Technologies Co.,Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,15 +18,37 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BUILD_DIR=${DIR}/../build LIB_PATH=${DIR}/../release/lib64 +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +KERNEL_OS=`uname -o` +KERNEL_MACHINE=`uname -m` +KERNEL_RELEASE=`uname -r` +KERNEL_VERSION=`uname -v` + +echo KERNEL_OS: $KERNEL_OS +echo KERNEL_MACHINE: $KERNEL_MACHINE +echo KERNEL_RELEASE: $KERNEL_RELEASE +echo KERNEL_VERSION: $KERNEL_VERSION +echo OS_ID: $OS_ID +echo OS_VERSION_ID: $OS_ID + #DPDK download path -DPDK_DOWNLOAD_PATH=/root/dpdk +DPDK_DOWNLOAD_PATH=/tmp/dpdk #dpdk installation path -DPDK_INSTALL_PATH=/root/dpdk_install/tmp +DPDK_INSTALL_PATH=/usr -#set and check the environment for Ubuntu +#set and check the environment for Linux #set env -apt-get install git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump +if [ "$OS_ID" == "ubuntu" ]; then + apt-get install git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump +elif [ "$OS_ID" == "debian" ]; then + apt-get install git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump +elif [ "$OS_ID" == "centos" ]; then + yum install git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump +elif [ "$OS_ID" == "opensuse" ]; then + yum install git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump +fi #check env isInFile=$(cat /etc/default/grub | grep -c "default_hugepagesz=1G hugepagesz=1G hugepages=8") @@ -35,7 +56,7 @@ if [ $isInFile -eq 0 ]; then echo "hugepage need to be set, set it by doing" echo "1. vi /etc/default/grub " echo "2. add the line GRUB_CMDLINE_LINUX_DEFAULT="default_hugepagesz=1G hugepagesz=1G hugepages=8" " - echo "3. perform " update-grub " " + echo "3. perform " update-grub " in ubuntu " grub2-mkconfig -o /boot/grub2/grub.cfg " in centos " echo "4. reboot" exit else @@ -43,7 +64,17 @@ else fi #DPDK will be having dependancy on linux headers -apt-get install git build-essential linux-headers-`uname -r` +if [ "$OS_ID" == "ubuntu" ]; then + apt-get install git build-essential linux-headers-`uname -r` +elif [ "$OS_ID" == "debian" ]; then + apt-get install git build-essential linux-headers-`uname -r` +elif [ "$OS_ID" == "centos" ]; then + yum groupinstall "Development Tools" + yum install kernel-headers +elif [ "$OS_ID" == "opensuse" ]; then + yum groupinstall "Development Tools" + yum install kernel-headers +fi hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0") if [ $hugepageTotal -ne 0 ]; then @@ -70,46 +101,46 @@ if [ $pdpe1gbFlag -eq 0 ]; then fi mkdir /mnt/nstackhuge -p -mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/ +sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/ -mkdir -p /var/run/ip_module/ +sudo mkdir -p /var/run/ip_module/ #===========build DPDK================ -if [ -d $DPDK_INSTALL_PATH ]; then - rm -rf $DPDK_INSTALL_PATH -fi -mkdir -p $DPDK_DOWNLOAD_PATH +if [ "$OS_ID" == "centos" ]; then + ./build_dpdk.sh +else + mkdir -p $DPDK_DOWNLOAD_PATH -cd $DPDK_DOWNLOAD_PATH -rm -rf dpdk-16.04/ -wget https://fast.dpdk.org/rel/dpdk-16.04.tar.xz -tar xvf dpdk-16.04.tar.xz -cd dpdk-16.04/ + cd $DPDK_DOWNLOAD_PATH + rm -rf dpdk-16.04/ + wget https://fast.dpdk.org/rel/dpdk-16.04.tar.xz + tar xvf dpdk-16.04.tar.xz + cd dpdk-16.04/ -sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base -sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base -sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base + sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base + sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base + sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base -make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -cd x86_64-native-linuxapp-gcc -make + make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} + cd x86_64-native-linuxapp-gcc + make +fi export LD_LIBRARY_PATH=$LIB_PATH export NSTACK_LOG_ON=DBG - #===========build DMM================= echo "DMM build started....." cd $LIB_PATH -rm -rf * +sudo rm -rf * cd ../../thirdparty/glog/glog-0.3.4/ sudo autoreconf -ivf cd $BUILD_DIR -rm -rf * -cmake -D DMM_DPDK_INSTALL_DIR=$DPDK_INSTALL_PATH .. -make -j 8 +sudo rm -rf * +sudo cmake .. +sudo make -j 8 echo "DMM build finished....." diff --git a/scripts/build_dpdk.sh b/scripts/build_dpdk.sh new file mode 100644 index 0000000..be5fc2c --- /dev/null +++ b/scripts/build_dpdk.sh @@ -0,0 +1,73 @@ +######################################################################### +# +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# 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. +######################################################################### +#!/bin/sh + +echo "check whether dpdk installed" +cur_directory=${PWD} +check_dpdk=$(rpm -qa | grep dpdk) +if [ -z "$check_dpdk" ]; then + echo "system will install the dpdk" +else + echo "system has installed the dpdk" + echo "$check_dpdk" + exit 0 +fi + +cd ~ +mkdir -p rpmbuild/SOURCES + +cd ~/rpmbuild/SOURCES +wget http://dpdk.org/browse/dpdk/snapshot/dpdk-16.04.tar.gz + +tar xzvf dpdk-16.04.tar.gz +cp dpdk-16.04/pkg/dpdk.spec ~/rpmbuild/SOURCES/ + +echo "modify the spec" + +#get rid of the dependence of xen-devel +sed -i '48d' dpdk.spec +sed -i '47a BuildRequires: kernel-devel, kernel-headers, libpcap-devel' dpdk.spec + +#get rid of the dependence of texlive-collection +sed -i '/BuildRequires: texlive-collection/s/^/#&/' dpdk.spec + +#delete something about xen +sed -i '/LIBRTE_PMD_XENVIRT/s/^/#&/' dpdk.spec +sed -i '/LIBRTE_XEN_DOM0/s/^/#&/' dpdk.spec + +#delete something of generating doc +sed -i '/%{target} doc/s/^/#&/' dpdk.spec +sed -i '94d' dpdk.spec +sed -i '93a datadir=%{_datadir}/dpdk' dpdk.spec +sed -i '94a # datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk' dpdk.spec +sed -i '/%files doc/s/^/#&/' dpdk.spec +sed -i '/%doc %{_docdir}/s/^/#&/' dpdk.spec + +sed -i '76a sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base' dpdk.spec +sed -i '77a sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base' dpdk.spec +sed -i '78a sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base' dpdk.spec + +echo "build the dependence" +sudo yum-builddep -y dpdk.spec + +echo "generate the rpm package" +rpmbuild -ba dpdk.spec --define "_sourcedir ${PWD}" + +echo "install the rpm" +cd ../RPMS/x86_64/ +sudo rpm -ivh dpdk-16.04-1.x86_64.rpm +sudo rpm -ivh dpdk-devel-16.04-1.x86_64.rpm +cd ${cur_directory} diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 78072c6..83e9d81 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -16,7 +16,7 @@ if(WITH_HAL_LIB) else() - SET(PAL_H_DIRECTORIES "${DMM_DPDK_INSTALL_DIR}/include/dpdk/") + SET(PAL_H_DIRECTORIES "/usr/include/dpdk/") FILE(GLOB_RECURSE LIBCOMM lib_common_mem/*.c) endif() @@ -57,4 +57,4 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_LIST_DIR}/../nSocket/nstack/event/ ${CMAKE_CURRENT_LIST_DIR}/../nSocket/nstack/event/epoll ${CMAKE_CURRENT_LIST_DIR}/../nSocket/include -)
\ No newline at end of file +) diff --git a/src/nSocket/CMakeLists.txt b/src/nSocket/CMakeLists.txt index 1063f58..5701e8e 100644 --- a/src/nSocket/CMakeLists.txt +++ b/src/nSocket/CMakeLists.txt @@ -17,35 +17,33 @@ if(WITH_HAL_LIB) else() - SET(PAL_H_DIRECTORIES "${DMM_DPDK_INSTALL_DIR}/include/dpdk/") - SET(DPDK_LIB_DIRECTORIES "${DMM_DPDK_INSTALL_DIR}/lib") - SET(DPDK_LIBS "${DPDK_LIB_DIRECTORIES}/librte_eal.so") - list(APPEND DPDK_LIBS "${DPDK_LIB_DIRECTORIES}/librte_mempool.so") - list(APPEND DPDK_LIBS "${DPDK_LIB_DIRECTORIES}/librte_mbuf.so") - list(APPEND DPDK_LIBS "${DPDK_LIB_DIRECTORIES}/librte_ring.so") + SET(PAL_H_DIRECTORIES "/usr/include/dpdk/") endif() INCLUDE_DIRECTORIES( - include/ - kernel/ - nstack/ - nstack/event/ - nstack/event/epoll - nstack/event/select - ${SECUREC_SRC_H} - ${PAL_H_DIRECTORIES} - ${CMAKE_CURRENT_LIST_DIR}/../adapt - ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/json/json-c-0.12.1 + include/ + kernel/ + nstack/ + nstack/event/ + nstack/event/epoll + nstack/event/select + ${SECUREC_SRC_H} + ${PAL_H_DIRECTORIES} + ${CMAKE_CURRENT_LIST_DIR}/../adapt + ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/json/json-c-0.12.1 ) FILE(GLOB_RECURSE nSocket *.c) ADD_LIBRARY(nStackAPI SHARED ${nSocket}) TARGET_LINK_LIBRARIES( - nStackAPI - -Wl,--whole-archive - ${LIB_PATH_STATIC}/libjson-c.a - ${LIB_PATH_STATIC}/libglog.a - dmm_api - -Wl,--no-whole-archive,-lstdc++ - ${DPDK_LIBS}) + nStackAPI + -Wl,--whole-archive + ${LIB_PATH_STATIC}/libjson-c.a + ${LIB_PATH_STATIC}/libglog.a + dmm_api + -Wl,--no-whole-archive,-lstdc++ + rte_eal + rte_mempool + rte_mbuf + rte_ring) ADD_DEPENDENCIES(nStackAPI dmm_api) |