Commit f1980244 authored by Yuriy Umanets's avatar Yuriy Umanets Committed by Tomasz Zawadzki
Browse files

configure: Fixes with IPSec_mb used by DPDK



- In case that --with-dpdk=dpdk/install option is used, we need to link
  with the proper IPSec_mb libs the DPDK was built with rather than using
  the default location of IPSec_mb submodule located inside the SPDK dir.
- Check with pkg-config if we need to link with IPSec_mb. Find the proper
  IPSec_mb library path for DPDK specified with --with-dpdk=dpdk/install
  option.
- Use the same behavior for plain --with-dpdk.

Signed-off-by: default avatarYuriy Umanets <yumanets@nvidia.com>
Change-Id: Iea56d20d20556d63cb7ffb5ce2ca78f2244796e1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11617


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 3e3fbf91
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -198,3 +198,6 @@ CONFIG_IDXD_KERNEL=n

# Is DPDK using libbsd?
CONFIG_HAVE_LIBBSD=n

# Path to IPSEC_MB used by DPDK
CONFIG_IPSEC_MB_DIR=
+67 −4
Original line number Diff line number Diff line
@@ -214,6 +214,65 @@ function find_dpdk_arch_libdir() {
	echo "$dpdk_dir/lib"
}

function check_IPSec_mb() {
	local mode=$1
	local dpdk_libdir=$2
	local dpdk_incdir=$3
	local have_ipsec_mb=n

	if [[ $mode = "pkg-config" ]]; then
		local dpdk_libs

		# Request libdpdk pkg-config settings to figure out if the IPSec_MB is used
		# as a dependency.
		# Due to some reason pkg-config shows -lIPSec_MB only with --static option
		dpdk_libs=$(PKG_CONFIG_PATH="$dpdk_libdir/pkgconfig" pkg-config --libs --static libdpdk)
		if echo "$dpdk_libs" | grep "\-lIPSec_MB" > /dev/null 2>&1; then
			have_ipsec_mb=y
		fi
	elif [[ $mode = "build-config" ]]; then
		# Use dpdk build config header to check if the IPSec_MB was used.
		if grep -F "define RTE_CRYPTO_IPSEC_MB 1" "$dpdk_incdir/rte_build_config.h" > /dev/null 2>&1; then
			have_ipsec_mb=y
		fi
	else
		echo "ERROR: Invalid IPSec_MB checking mode $mode."
		echo "ERROR: Only \"pkg-config\" and \"build-config\" available."
		exit 1
	fi
	if [[ $have_ipsec_mb = "n" ]]; then
		CONFIG[IPSEC_MB]=n
		return
	fi

	# Since we don't know the library path where the IPSec_MB is located
	# let's find it out with the ldd utility. This can be a standard location
	# or a custom build.
	local librte_crypto_ipsec_mb="$dpdk_libdir/librte_crypto_ipsec_mb.so"
	if [[ -f "$librte_crypto_ipsec_mb" ]]; then
		local ipsec_mb_libdir

		ipsec_mb_libdir=$(ldd "$librte_crypto_ipsec_mb" | grep "libIPSec_MB.so" \
			| sed -e 's/\s*libIPSec_MB.so.*=>\s//' -e 's/\/libIPSec_MB.so.*$//')
		if [[ -d $ipsec_mb_libdir ]]; then
			CONFIG[IPSEC_MB]=y
			CONFIG[IPSEC_MB_DIR]="$ipsec_mb_libdir"
		elif [[ $ipsec_mb_libdir = "not found" ]]; then
			# ldconfig cache is broken, old build with refs to non-existing libs, etc.
			echo "ERROR: Invalid IPSec_MB installation. Library is not found and/or ldconfig cache is broken!"
			exit 1
		else
			# Failed to check for IPSec_MB lib path. Let's just assume it is lives
			# in one of the standard locations (/usr/lib, etc.).
			CONFIG[IPSEC_MB]=y
		fi
	else
		# pkg-config says there is IPSec_mb and dpdk lib does not have it. Let's just
		# assume it is installed in the system in one of the standard locations.
		CONFIG[IPSEC_MB]=y
	fi
}

for i in "$@"; do
	case "$i" in
		-h | --help)
@@ -323,6 +382,7 @@ for i in "$@"; do
					CONFIG[HAVE_LIBBSD]=y
				fi
				CFLAGS="${CFLAGS:+$CFLAGS }$(pkg-config --cflags libdpdk)"
				check_IPSec_mb "pkg-config" "$dpdk_libdir" "$dpdk_incdir"
			else
				echo "libdpdk.pc not found, aborting"
				exit 1
@@ -350,12 +410,14 @@ for i in "$@"; do
				fi
				CFLAGS="${CFLAGS:+$CFLAGS }$(PKG_CONFIG_PATH="$dpdk_libdir/pkgconfig" pkg-config --cflags libdpdk)"
				dpdk_incdir=$(PKG_CONFIG_PATH="$dpdk_libdir/pkgconfig" pkg-config --variable=includedir libdpdk)
				check_IPSec_mb "pkg-config" "$dpdk_libdir" "$dpdk_incdir"
			else
				echo "Using $dpdk_incdir/rte_build_config.h for additional libs..."

				if grep -F "define RTE_USE_LIBBSD 1" $dpdk_incdir/rte_build_config.h > /dev/null 2>&1; then
					CONFIG[HAVE_LIBBSD]=y
				fi
				check_IPSec_mb "build-config" "$dpdk_libdir" "$dpdk_incdir"
			fi
			echo "DPDK libraries: $dpdk_libdir"
			echo "DPDK includes: $dpdk_incdir"
@@ -640,6 +702,11 @@ if [ -z "${CONFIG[ENV]}" ]; then
			exit 1
		else
			CONFIG[DPDK_DIR]="${rootdir}/dpdk/build"
			# Default ipsec libs
			if [[ "${CONFIG[CRYPTO]}" = "y" ]]; then
				CONFIG[IPSEC_MB]=y
				CONFIG[IPSEC_MB_DIR]="${rootdir}/intel-ipsec-mb/lib"
			fi
			echo "Using default DPDK in ${CONFIG[DPDK_DIR]}"
		fi
	fi
@@ -791,10 +858,6 @@ if [[ "${CONFIG[ISAL]}" = "y" ]] || [[ "${CONFIG[CRYPTO]}" = "y" ]]; then
		echo "ERROR: ISA-L, compression & crypto require NASM version 2.14 or newer."
		echo "Please install or upgrade them re-run this script."
		exit 1
	else
		if [[ "${CONFIG[CRYPTO]}" = "y" ]]; then
			CONFIG[IPSEC_MB]=y
		fi
	fi
fi

+4 −1
Original line number Diff line number Diff line
@@ -141,7 +141,10 @@ ENV_CXXFLAGS = $(ENV_CFLAGS)
DPDK_PRIVATE_LINKER_ARGS =

ifeq ($(CONFIG_IPSEC_MB),y)
DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB -L$(IPSEC_MB_DIR)
DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB
ifneq ($(IPSEC_MB_DIR),)
DPDK_PRIVATE_LINKER_ARGS += -L$(IPSEC_MB_DIR)
endif
endif

ifeq ($(CONFIG_HAVE_LIBBSD),y)
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ LDFLAGS += -L$(CONFIG_URING_PATH)
endif
endif

IPSEC_MB_DIR=$(SPDK_ROOT_DIR)/intel-ipsec-mb/lib
IPSEC_MB_DIR=$(CONFIG_IPSEC_MB_DIR)

ISAL_DIR=$(SPDK_ROOT_DIR)/isa-l
ifeq ($(CONFIG_ISAL), y)