From 737b1b571b7f04987151fadaaa63f75809fd3613 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Mon, 8 May 2017 15:07:13 -0700 Subject: [PATCH] build: add dpdk as a submodule This will allow a git clone to default to an SPDK-specific version of the DPDK repository. Users can still override to use a separate DPDK repository/installation with the --with-dpdk configure script options. While here, remove gzip option for the git-archive operations in autopackage.sh. We need to add a git-archive for the DPDK submodule if we are using it, and compressing at -9 adds a lot of unnecessary time. Since we are not archiving these packages, there is no need to compress them. Also explicitly disable coverage and ubsan for the autopackage build, since this build is only to test compilation and is not actually used for any test execution. Signed-off-by: Jim Harris Change-Id: I3cf8a2ed984003a175cdece6542636ede8cb2479 --- .gitmodules | 3 ++ Makefile | 6 ++++ README.md | 35 ++++++++++-------- autopackage.sh | 25 +++++++++---- configure | 5 ++- dpdk | 1 + dpdkbuild/Makefile | 72 ++++++++++++++++++++++++++++++++++++++ scripts/autotest_common.sh | 17 +++++++-- scripts/vagrant/build.sh | 6 +--- 9 files changed, 138 insertions(+), 32 deletions(-) create mode 100644 .gitmodules create mode 160000 dpdk create mode 100644 dpdkbuild/Makefile diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..d0ecf725f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dpdk"] + path = dpdk + url = https://github.com/spdk/dpdk.git diff --git a/Makefile b/Makefile index 93cbf29e9..8ab3ac7bc 100644 --- a/Makefile +++ b/Makefile @@ -40,11 +40,17 @@ DIRS-y += lib test examples app .PHONY: all clean $(DIRS-y) config.h CONFIG.local mk/cc.mk +ifeq ($(CURDIR)/dpdk/build,$(CONFIG_DPDK_DIR)) +DPDKBUILD = dpdkbuild +DIRS-y += dpdkbuild +endif + all: $(DIRS-y) clean: $(DIRS-y) $(Q)rm -f mk/cc.mk $(Q)rm -f config.h +lib: $(DPDKBUILD) app: lib test: lib examples: lib diff --git a/README.md b/README.md index 4f62efc5c..3c7ed516e 100644 --- a/README.md +++ b/README.md @@ -53,20 +53,13 @@ FreeBSD: sudo pkg install gmake cunit openssl -Additionally, [DPDK](http://dpdk.org/doc/quick-start) is required. +Additionally, [DPDK](http://dpdk.org/doc/quick-start) is required. The SPDK +repository includes a suitable version of DPDK as a submodule. Newer versions +of git will automatically fetch the DPDK submodule. Older versions of git may +require: - 1) cd /path/to/spdk - 2) wget http://fast.dpdk.org/rel/dpdk-17.02.tar.xz - 3) tar xf dpdk-17.02.tar.xz - 4) mv dpdk-17.02 dpdk - -Linux: - - 4) (cd dpdk && make install T=x86_64-native-linuxapp-gcc DESTDIR=.) - -FreeBSD: - - 4) (cd dpdk && gmake install T=x86_64-native-bsdapp-clang DESTDIR=.) + 1) git submodule init + 2) git submodule update Building ======== @@ -94,8 +87,6 @@ quickly. Currently this has only been tested on MacOS with the [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads) must also be installed for NVMe support. -Download DPDK as a subdirectory in the SPDK repository as described above. -You do *not* need to build DPDK - the Vagrant scripts will do this for you. If you are behind a corporate firewall, set http_proxy and https_proxy in your environment before running the following steps. @@ -135,6 +126,20 @@ line: make CONFIG_RDMA=y +Users may wish to use a version of DPDK different from the submodule included +in the SPDK repository. To specify an alternate DPDK installation, run +configure with the --with-dpdk option. For example: + +Linux: + + ./configure --with-dpdk=/path/to/dpdk/x86_64-native-linuxapp-gcc + make + +FreeBSD: + + ./configure --with-dpdk=/path/to/dpdk/x86_64-native-bsdapp-clang + gmake + The options specified on the `make` command line take precedence over the default values in `CONFIG` and `CONFIG.local`. This can be useful if you, for example, generate a `CONFIG.local` using the `configure` script and then have diff --git a/autopackage.sh b/autopackage.sh index 7f5959b2a..1c27f8931 100755 --- a/autopackage.sh +++ b/autopackage.sh @@ -20,20 +20,31 @@ if [ `git status --porcelain | wc -l` -ne 0 ]; then exit 1 fi -pv=spdk-$(date +%Y_%m_%d) +spdk_pv=spdk-$(date +%Y_%m_%d) +spdk_tarball=${spdk_pv}.tar +dpdk_pv=dpdk-$(date +%Y_%m_%d) +dpdk_tarball=${dpdk_pv}.tar -find . -iname "spdk-*.tar.gz" -delete -git archive HEAD -9 --prefix=${pv}/ -o ${pv}.tar.gz - -tarball=$(ls -1 spdk-*.tar.gz) +find . -iname "spdk-*.tar* dpdk-*.tar*" -delete +git archive HEAD --prefix=${spdk_pv}/ -o ${spdk_tarball} # Build from packaged source tmpdir=$(mktemp -d) echo "tmpdir=$tmpdir" -tar -C "$tmpdir" -xf $tarball +tar -C "$tmpdir" -xf $spdk_tarball + +if [ -z "$WITH_DPDK_DIR" ]; then + cd dpdk + git archive HEAD --prefix=dpdk/ -o ../${dpdk_tarball} + cd .. + tar -C "$tmpdir/${spdk_pv}" -xf $dpdk_tarball +fi + ( cd "$tmpdir"/spdk-* - ./configure $config_params --disable-debug --enable-werror + # use $config_params to get the right dependency options, but disable coverage and ubsan + # explicitly since they are not needed for this build + ./configure $config_params --disable-debug --enable-werror --disable-coverage --disable-ubsan time $MAKE ${MAKEFLAGS} ) rm -rf "$tmpdir" diff --git a/configure b/configure index 18fa97958..d907a2fd6 100755 --- a/configure +++ b/configure @@ -27,7 +27,7 @@ function usage() echo " disable features and components." echo "" echo "Valid dependencies are listed below." - echo " dpdk Required unless providing an alternate env implementation." + echo " dpdk Optional. Uses dpdk submodule in spdk tree if not specified." echo " example: /usr/share/dpdk/x86_64-default-linuxapp-gcc" echo " fio Required to build fio_plugin." echo " example: /usr/src/fio" @@ -121,8 +121,7 @@ done if [ -z "$CONFIG_ENV" ]; then if [ -z "$CONFIG_DPDK_DIR" ]; then - echo "You must specify the path to dpdk using --with-dpdk=path." - exit 1 + CONFIG_DPDK_DIR=$(readlink -f $(dirname $0))/dpdk/build fi fi diff --git a/dpdk b/dpdk new file mode 160000 index 000000000..4811908e7 --- /dev/null +++ b/dpdk @@ -0,0 +1 @@ +Subproject commit 4811908e7fc15433f40b7555b0e7ac97caa7e0cd diff --git a/dpdkbuild/Makefile b/dpdkbuild/Makefile new file mode 100644 index 000000000..3c92bfe58 --- /dev/null +++ b/dpdkbuild/Makefile @@ -0,0 +1,72 @@ +# +# BSD LICENSE +# +# Copyright (c) Intel Corporation. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +SPDK_ROOT_DIR := $(abspath $(CURDIR)/..) +include $(SPDK_ROOT_DIR)/mk/spdk.common.mk + +.PHONY: all clean + +DPDK_CONFIG := spdk + +ifeq ($(OS),Linux) +DPDK_CONFIG := $(DPDK_CONFIG)-linuxapp +else +ifeq ($(OS),FreeBSD) +DPDK_CONFIG := $(DPDK_CONFIG)-bsdapp +endif +endif + +ifeq ($(CC_TYPE),clang) +DPDK_CONFIG := $(DPDK_CONFIG)-clang +else +DPDK_CONFIG := $(DPDK_CONFIG)-gcc +endif + +NPROC = $(shell nproc) + +ifeq ($(CONFIG_FIO_PLUGIN),y) +DPDK_CFLAGS = -fPIC +endif + +ifeq ($(CONFIG_DEBUG),y) +DPDK_CFLAGS += -O0 +endif + +$(SPDK_ROOT_DIR)/dpdk/build: + $(Q)$(MAKE) -C $(SPDK_ROOT_DIR)/dpdk config T=$(DPDK_CONFIG) + +all: $(SPDK_ROOT_DIR)/dpdk/build + $(Q)$(MAKE) -C $(SPDK_ROOT_DIR)/dpdk/build EXTRA_CFLAGS="$(DPDK_CFLAGS)" MAKEFLAGS="T=$(DPDK_CONFIG) -j$(NPROC)" + +clean: + $(Q)rm -rf $(SPDK_ROOT_DIR)/dpdk/build diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index 543751707..51a8d114d 100755 --- a/scripts/autotest_common.sh +++ b/scripts/autotest_common.sh @@ -29,12 +29,18 @@ export NRHUGE=4096 case `uname` in FreeBSD) - config_params+=' --with-dpdk=/usr/local/share/dpdk/x86_64-native-bsdapp-clang' + DPDK_FREEBSD_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang + if [ -d $DPDK_FREEBSD_DIR ]; then + WITH_DPDK_DIR=$DPDK_FREEBSD_DIR + fi MAKE=gmake MAKEFLAGS=${MAKEFLAGS:--j$(sysctl -a | egrep -i 'hw.ncpu' | awk '{print $2}')} ;; Linux) - config_params+=' --with-dpdk=/usr/local/share/dpdk/x86_64-native-linuxapp-gcc' + DPDK_LINUX_DIR=/usr/local/share/dpdk/x86_64-native-linuxapp-gcc + if [ -d $DPDK_LINUX_DIR ]; then + WITH_DPDK_DIR=$DPDK_LINUX_DIR + fi MAKE=make MAKEFLAGS=${MAKEFLAGS:--j$(nproc)} config_params+=' --enable-coverage' @@ -46,6 +52,13 @@ case `uname` in ;; esac +# By default, --with-dpdk is not set meaning the SPDK build will use the DPDK submodule. +# If a DPDK installation is found in a well-known location though, WITH_DPDK_DIR will be +# set which will override the default and use that DPDK installation instead. +if [ ! -z "$WITH_DPDK_DIR" ]; then + config_params+=" --with-dpdk=$WITH_DPDK_DIR" +fi + if [ -f /usr/include/infiniband/verbs.h ]; then config_params+=' --with-rdma' fi diff --git a/scripts/vagrant/build.sh b/scripts/vagrant/build.sh index b4f7f9660..f3c2f1e02 100644 --- a/scripts/vagrant/build.sh +++ b/scripts/vagrant/build.sh @@ -1,7 +1,6 @@ #!/bin/bash SPDK_DIR=/spdk -DPDK_DIR=$SPDK_DIR/dpdk SUDOCMD="sudo -H -u vagrant" echo 0:$0 @@ -41,11 +40,8 @@ elif [ -f /etc/redhat-release ]; then yum install -y gcc gcc-c++ CUnit-devel libaio-devel openssl-devel fi -cd $DPDK_DIR -$SUDOCMD make -j2 install T=x86_64-native-linuxapp-gcc DESTDIR=. - cd $SPDK_DIR -$SUDOCMD ./configure --with-dpdk=$DPDK_DIR/x86_64-native-linuxapp-gcc --enable-debug +$SUDOCMD ./configure --enable-debug $SUDOCMD make -j2 # Bind virtual NVMe controller to uio_pci_generic sudo scripts/setup.sh