spdk: Add ISA-L support with related crc32 function

In SPDK, we will build isa-l with no shared option
and then integrate it into SPDK. And we do not need
to install isal in the system libaries.

Note: ocf build in autobuild.sh now needs to build
include/spdk/config.h before building the ocf library,
to ensure that header is available in a clean build
environment.

Change-Id: I3f0ce6932b386de17a77cf5bfdfd738b22417e2d
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Signed-off-by: paul luse <paul.e.luse@intel.com>
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Reviewed-on: https://review.gerrithub.io/c/441279
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Chunyang Hui <chunyang.hui@intel.com>
This commit is contained in:
Ziye Yang 2019-01-21 17:05:59 +08:00 committed by Darek Stojaczyk
parent d3bfd244f0
commit 552e21cce6
15 changed files with 158 additions and 7 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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.

3
CONFIG
View File

@ -129,3 +129,6 @@ CONFIG_IPSEC_MB=n
CONFIG_OCF=n
CONFIG_OCF_PATH=
CONFIG_CUSTOMOCF=n
# Build ISA-L library
CONFIG_ISAL=y

View File

@ -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

View File

@ -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"

View File

@ -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

52
configure vendored
View File

@ -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

View File

@ -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 <isa-l/include/crc.h>
#else
#define SPDK_HAVE_SSE4_2
#include <x86intrin.h>
#endif
#endif
/**
* IEEE CRC-32 polynomial (bit reflected)
*/

1
isa-l Submodule

@ -0,0 +1 @@
Subproject commit 09e787231b31add1234ec9a3dfe718533f1c3bf4

49
isalbuild/Makefile Normal file
View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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