diff --git a/.gitmodules b/.gitmodules index f1d223b71..1dc55f164 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "intel-ipsec-mb"] path = intel-ipsec-mb url = https://github.com/spdk/intel-ipsec-mb.git +[submodule "isa-l"] + path = isa-l + url = https://github.com/spdk/isa-l.git diff --git a/CHANGELOG.md b/CHANGELOG.md index a6f7f13c8..fa999dad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ A new public header file env_dpdk.h has been introduced, and function spdk_env_d is added into it. If user is using DPDK, and already called rte_eal_init, then include include/spdk/env_dpdk.h, and call spdk_env_dpdk_post_init() instead of spdk_env_init. +ISA-L has been added as an SPDK submodule. ISA-L is enabled by default on x86 architecture +to accelerate algorithms such as CRC for iSCSI and NVMe-oF. Users may still disable ISA-L +by explicitly passing --without-isal to the configure script. + ### util A new uuid API `spdk_uuid_copy` was added to make a copy of the source uuid. diff --git a/CONFIG b/CONFIG index 5a4c20edb..4267be93c 100644 --- a/CONFIG +++ b/CONFIG @@ -129,3 +129,6 @@ CONFIG_IPSEC_MB=n CONFIG_OCF=n CONFIG_OCF_PATH= CONFIG_CUSTOMOCF=n + +# Build ISA-L library +CONFIG_ISAL=y diff --git a/Makefile b/Makefile index c6ecb9750..113eedf49 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ DIRS-$(CONFIG_SHARED) += shared_lib DIRS-y += examples app include DIRS-$(CONFIG_TESTS) += test DIRS-$(CONFIG_IPSEC_MB) += ipsecbuild +DIRS-$(CONFIG_ISAL) += isalbuild .PHONY: all clean $(DIRS-y) include/spdk/config.h mk/config.mk mk/cc.mk \ cc_version cxx_version .libs_only_other .ldflags ldflags @@ -64,6 +65,10 @@ ifeq ($(CONFIG_IPSEC_MB),y) LIB += ipsecbuild endif +ifeq ($(CONFIG_ISAL),y) +LIB += isalbuild +endif + all: $(DIRS-y) clean: $(DIRS-y) $(Q)rm -f mk/cc.mk diff --git a/autobuild.sh b/autobuild.sh index 51c80b93c..becb9c972 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -19,6 +19,7 @@ if [ "$SPDK_TEST_OCF" -eq 1 ]; then # They don't need to be checked with scanbuild and code coverage is not applicable # So we precompile OCF now for further use as standalone static library ./configure $(echo $config_params | sed 's/--enable-coverage//g') + $MAKE $MAKEFLAGS include/spdk/config.h CC=gcc CCAR=ar $MAKE $MAKEFLAGS -C lib/bdev/ocf/env exportlib O=$rootdir/build/ocf.a # Set config to use precompiled library config_params="$config_params --with-ocf=/$rootdir/build/ocf.a" diff --git a/autopackage.sh b/autopackage.sh index ed898ee5e..33cd88ccc 100755 --- a/autopackage.sh +++ b/autopackage.sh @@ -26,8 +26,10 @@ dpdk_pv=dpdk-$(date +%Y_%m_%d) dpdk_tarball=${dpdk_pv}.tar ipsec_pv=ipsec-$(date +%Y_%m_%d) ipsec_tarball=${ipsec_pv}.tar +isal_pv=isal-$(date +%Y_%m_%d) +isal_tarball=${isal_pv}.tar -find . -iname "spdk-*.tar* dpdk-*.tar* ipsec-*.tar*" -delete +find . -iname "spdk-*.tar* dpdk-*.tar* ipsec-*.tar* isal-*.tar*" -delete git archive HEAD^{tree} --prefix=${spdk_pv}/ -o ${spdk_tarball} # Build from packaged source @@ -49,6 +51,13 @@ if [ -d "intel-ipsec-mb" ]; then tar -C "$tmpdir/${spdk_pv}" -xf $ipsec_tarball fi +if [ -d "isa-l" ]; then + cd isa-l + git archive HEAD^{tree} --prefix=isa-l/ -o ../${isal_tarball} + cd .. + tar -C "$tmpdir/${spdk_pv}" -xf $isal_tarball +fi + ( cd "$tmpdir"/spdk-* # use $config_params to get the right dependency options, but disable coverage and ubsan diff --git a/configure b/configure index 492fe09c8..962ff6170 100755 --- a/configure +++ b/configure @@ -66,6 +66,8 @@ function usage() echo " If argument is directory, interpret it as root of OCF repo" echo " If argument is file, interpret it as compiled OCF lib" echo " example: /usr/src/ocf/" + echo " isal Enabled by default on x86 architecture. Can be built without though." + echo " No path required." echo "" echo "Environment variables:" echo "" @@ -281,6 +283,12 @@ for i in "$@"; do CONFIG[OCF]=n CONFIG[OCF_PATH]= ;; + --with-isal) + CONFIG[ISAL]=y + ;; + --without-isal) + CONFIG[ISAL]=n + ;; --) break ;; @@ -291,6 +299,13 @@ for i in "$@"; do esac done +# Detect architecture and force no isal if non x86 archtecture +arch=$(uname -i) +if [[ $arch != x86_64* ]]; then + echo "Notice: ISAL auto-disabled due to CPU incompatiblity." + CONFIG[ISAL]=n +fi + if [ -z "${CONFIG[ENV]}" ]; then rootdir=$(readlink -f $(dirname $0)) CONFIG[ENV]=$rootdir/lib/env_dpdk @@ -385,13 +400,40 @@ than or equal to 4.14 will see significantly reduced performance. fi fi -if [[ "${CONFIG[CRYPTO]}" = "y" ]]; then - if [[ $(nasm -v | sed 's/[^0-9]*//g' | awk '{print substr ($0, 0, 5)}') -lt "21202" ]]; then - echo Crypto requires NASM version 2.12.02 or newer. Please install - echo or upgrade then re-run this script. +if [[ "${CONFIG[ISAL]}" = "y" ]] || [[ "${CONFIG[CRYPTO]}" = "y" ]]; then + if [[ $(nasm -v | sed 's/[^0-9]*//g' | awk '{print substr ($0, 0, 5)}') -lt "21202" ]]; then + echo "Notice: ISAL, compression & crypto auto-disabled due to nasm dependency." + echo "These features require NASM version 2.12.02 or newer. Please install" + echo "or upgrade then re-run this script." + CONFIG[ISAL]=n + CONFIG[CRYPTO]=n + CONFIG[IPSEC_MB]=n + else + if [[ "${CONFIG[CRYPTO]}" = "y" ]]; then + CONFIG[IPSEC_MB]=y + fi + fi +fi + +if [[ "${CONFIG[ISAL]}" = "y" ]]; then + if [ ! -d "$rootdir"/isa-l ]; then + echo "isa-l folder is not found; If you do want to install isa-l, run:" + echo " git submodule update --init" exit 1 fi - CONFIG[IPSEC_MB]=y + + if [[ "${CONFIG[RBD]}" = "y" ]]; then + echo "ISAL and RBD cannot co-exist currently so disabling ISAL." + CONFIG[ISAL]=n + else + cd $rootdir/isa-l + ISAL_LOG=/tmp/spdk-isal.log + echo -n "Configuring ISA-L (logfile: $ISAL_LOG)..." + ./autogen.sh &> $ISAL_LOG + ./configure CFLAGS="-fPIC -g -O2" --enable-shared=no >> $ISAL_LOG 2>&1 + echo "done." + cd $rootdir + fi fi if [[ "${CONFIG[REDUCE]}" = "y" ]]; then diff --git a/include/spdk/crc32.h b/include/spdk/crc32.h index 2074d3ad8..dbe961f12 100644 --- a/include/spdk/crc32.h +++ b/include/spdk/crc32.h @@ -40,6 +40,7 @@ #define SPDK_CRC32_H #include "spdk/stdinc.h" +#include "spdk/config.h" #ifdef __cplusplus extern "C" { @@ -53,9 +54,14 @@ extern "C" { #endif #if defined(__x86_64__) && defined(__SSE4_2__) +#ifdef SPDK_CONFIG_ISAL +#define SPDK_HAVE_ISAL +#include +#else #define SPDK_HAVE_SSE4_2 #include #endif +#endif /** * IEEE CRC-32 polynomial (bit reflected) */ diff --git a/isa-l b/isa-l new file mode 160000 index 000000000..09e787231 --- /dev/null +++ b/isa-l @@ -0,0 +1 @@ +Subproject commit 09e787231b31add1234ec9a3dfe718533f1c3bf4 diff --git a/isalbuild/Makefile b/isalbuild/Makefile new file mode 100644 index 000000000..3fc8171bb --- /dev/null +++ b/isalbuild/Makefile @@ -0,0 +1,49 @@ +# +# 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 install + +ifneq ($(Q),) +REDIRECT=> /dev/null +endif + +all: + $(Q)$(MAKE) -C $(SPDK_ROOT_DIR)/isa-l -j$(NPROC) all CC=cc $(REDIRECT) + +install: all + +clean: + $(Q)$(MAKE) -C $(SPDK_ROOT_DIR)/isa-l clean $(REDIRECT) diff --git a/lib/util/crc32c.c b/lib/util/crc32c.c index a8a35a57a..65c8a673c 100644 --- a/lib/util/crc32c.c +++ b/lib/util/crc32c.c @@ -33,7 +33,15 @@ #include "spdk/crc32.h" -#ifdef SPDK_HAVE_SSE4_2 +#ifdef SPDK_HAVE_ISAL + +uint32_t +spdk_crc32c_update(const void *buf, size_t len, uint32_t crc) +{ + return crc32_iscsi((unsigned char *)buf, len, crc); +} + +#elif defined(SPDK_HAVE_SSE4_2) uint32_t spdk_crc32c_update(const void *buf, size_t len, uint32_t crc) diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk index 1e5bff5c2..52e28a46f 100644 --- a/mk/spdk.common.mk +++ b/mk/spdk.common.mk @@ -144,6 +144,12 @@ endif IPSEC_MB_DIR=$(SPDK_ROOT_DIR)/intel-ipsec-mb +ISAL_DIR=$(SPDK_ROOT_DIR)/isa-l +ifeq ($(CONFIG_ISAL), y) +SYS_LIBS += -L$(ISAL_DIR)/.libs -lisal +COMMON_CFLAGS += -I$(ISAL_DIR)/.. +endif + #Attach only if FreeBSD and RDMA is specified with configure ifeq ($(OS),FreeBSD) ifeq ($(CONFIG_RDMA),y) diff --git a/scripts/pkgdep.sh b/scripts/pkgdep.sh index fb5074de3..c385604ed 100755 --- a/scripts/pkgdep.sh +++ b/scripts/pkgdep.sh @@ -71,6 +71,8 @@ if [ -s /etc/redhat-release ]; then if ! echo "$ID $VERSION_ID" | egrep -q 'rhel 7|centos 7'; then yum install -y python3-configshell python3-pexpect fi + # Additional dependencies for ISA-L used in compression + yum install -y autoconf automake libtool elif [ -f /etc/debian_version ]; then # Includes Ubuntu, Debian apt-get install -y gcc g++ make libcunit1-dev libaio-dev libssl-dev \ @@ -86,6 +88,8 @@ elif [ -f /etc/debian_version ]; then # Additional dependencies for SPDK CLI - not available on older Ubuntus apt-get install -y python3-configshell-fb python3-pexpect || echo \ "Note: Some SPDK CLI dependencies could not be installed." + # Additional dependencies for ISA-L used in compression + apt-get install -y autoconf automake libtool elif [ -f /etc/SuSE-release ]; then zypper install -y gcc gcc-c++ make cunit-devel libaio-devel libopenssl-devel \ git-core lcov python-base python-pep8 libuuid-devel sg3_utils pciutils @@ -99,11 +103,15 @@ elif [ -f /etc/SuSE-release ]; then zypper install -y libpmemblk-devel # Additional dependencies for building docs zypper install -y doxygen mscgen graphviz + # Additional dependencies for ISA-L used in compression + zypper install -y autoconf automake libtool elif [ $(uname -s) = "FreeBSD" ] ; then pkg install -y gmake cunit openssl git devel/astyle bash py27-pycodestyle \ python misc/e2fsprogs-libuuid sysutils/sg3_utils nasm # Additional dependencies for building docs pkg install -y doxygen mscgen graphviz + # Additional dependencies for ISA-L used in compression + pkg install -y autoconf automake libtool else echo "pkgdep: unknown system type." exit 1 diff --git a/scripts/vagrant/autorun-spdk.conf b/scripts/vagrant/autorun-spdk.conf index 4a2c885c3..3ee8f3eca 100644 --- a/scripts/vagrant/autorun-spdk.conf +++ b/scripts/vagrant/autorun-spdk.conf @@ -4,6 +4,7 @@ SPDK_RUN_CHECK_FORMAT=1 SPDK_RUN_SCANBUILD=1 SPDK_RUN_VALGRIND=1 SPDK_TEST_UNITTEST=1 +SPDK_TEST_ISAL=1 SPDK_TEST_ISCSI=0 SPDK_TEST_ISCSI_INITIATOR=0 SPDK_TEST_NVME=0 diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 3f257e4b9..28760ff01 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -40,6 +40,7 @@ fi : ${SPDK_RUN_SCANBUILD=1}; export SPDK_RUN_SCANBUILD : ${SPDK_RUN_VALGRIND=1}; export SPDK_RUN_VALGRIND : ${SPDK_TEST_UNITTEST=1}; export SPDK_TEST_UNITTEST +: ${SPDK_TEST_ISAL=1}; export SPDK_TEST_ISAL : ${SPDK_TEST_ISCSI=1}; export SPDK_TEST_ISCSI : ${SPDK_TEST_ISCSI_INITIATOR=1}; export SPDK_TEST_ISCSI_INITIATOR : ${SPDK_TEST_NVME=1}; export SPDK_TEST_NVME @@ -197,6 +198,10 @@ if [ $SPDK_TEST_FTL -eq 1 ]; then config_params+=' --with-ftl' fi +if [ $SPDK_TEST_ISAL -eq 0 ]; then + config_params+=' --without-isal' +fi + export config_params if [ -z "$output_dir" ]; then