Commit a1280c98 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

scripts: replace PCI_WHITELIST with PCI_ALLOWED



Similarly replace PCI_BLACKLIST with PCI_BLOCKED.

Use of ALLOWED/BLOCKED matches similar changes made
in DPDK.

While here, replace use of term "blacklist" with "blocked"
in one of the nvme perf scripts.  The usage there was
associated with how devices are blocked by using the
environment variables that are changed by this patch.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I720d99118ba5e050f436612c9fd415db44294a63
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5275


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 895ad892
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ rm -f /var/tmp/spdk*.sock

if [ $(uname -s) = Linux ]; then
	# OCSSD devices drivers don't support IO issues by kernel so
	# detect OCSSD devices and blacklist them (unbind from any driver).
	# detect OCSSD devices and block them (unbind from any driver).
	# If test scripts want to use this device it needs to do this explicitly.
	#
	# If some OCSSD device is bound to other driver than nvme we won't be able to
@@ -100,26 +100,26 @@ if [ $(uname -s) = Linux ]; then
		# Send Open Channel 2.0 Geometry opcode "0xe2" - not supported by NVMe device.
		if nvme admin-passthru $dev --namespace-id=1 --data-len=4096 --opcode=0xe2 --read > /dev/null; then
			bdf="$(basename $(readlink -e /sys/class/nvme/${dev#/dev/}/device))"
			echo "INFO: blacklisting OCSSD device: $dev ($bdf)"
			PCI_BLACKLIST+=" $bdf"
			echo "INFO: blocking OCSSD device: $dev ($bdf)"
			PCI_BLOCKED+=" $bdf"
			OCSSD_PCI_DEVICES+=" $bdf"
		fi
	done < <(find /dev -maxdepth 1 -regex '/dev/nvme[0-9]+' -print0)

	export OCSSD_PCI_DEVICES

	# Now, bind blacklisted devices to pci-stub module. This will prevent
	# Now, bind blocked devices to pci-stub module. This will prevent
	# automatic grabbing these devices when we add device/vendor ID to
	# proper driver.
	if [[ -n "$PCI_BLACKLIST" ]]; then
	if [[ -n "$PCI_BLOCKED" ]]; then
		# shellcheck disable=SC2097,SC2098
		PCI_WHITELIST="$PCI_BLACKLIST" \
			PCI_BLACKLIST="" \
		PCI_ALLOWED="$PCI_BLOCKED" \
			PCI_BLOCKED="" \
			DRIVER_OVERRIDE="pci-stub" \
			./scripts/setup.sh

		# Export our blacklist so it will take effect during next setup.sh
		export PCI_BLACKLIST
		# Export our blocked list so it will take effect during next setup.sh
		export PCI_BLOCKED
	fi
fi

+2 −2
Original line number Diff line number Diff line
@@ -47,11 +47,11 @@ $ 5d:05.5 RAID bus controller: Intel Corporation Device 201d (rev 04)
$ d7:05.5 RAID bus controller: Intel Corporation Device 201d (rev 04)
```

Run setup.sh script with VMD devices set in PCI_WHITELIST.
Run setup.sh script with VMD devices set in PCI_ALLOWED.

Example:
```
$ PCI_WHITELIST="0000:5d:05.5 0000:d7:05.5" scripts/setup.sh
$ PCI_ALLOWED="0000:5d:05.5 0000:d7:05.5" scripts/setup.sh
```

Check for available devices behind the VMD with spdk_lspci.
+11 −11
Original line number Diff line number Diff line
# Common shell utility functions

# Check if PCI device is on PCI_WHITELIST and not on PCI_BLACKLIST
# Check if PCI device is in PCI_ALLOWED and not in PCI_BLOCKED
# Env:
# if PCI_WHITELIST is empty assume device is whitelistened
# if PCI_BLACKLIST is empty assume device is NOT blacklistened
# if PCI_ALLOWED is empty assume device is allowed
# if PCI_BLOCKED is empty assume device is NOT blocked
# Params:
# $1 - PCI BDF
function pci_can_use() {
	local i

	# The '\ ' part is important
	if [[ " $PCI_BLACKLIST " =~ \ $1\  ]]; then
	if [[ " $PCI_BLOCKED " =~ \ $1\  ]]; then
		return 1
	fi

	if [[ -z "$PCI_WHITELIST" ]]; then
		#no whitelist specified, bind all devices
	if [[ -z "$PCI_ALLOWED" ]]; then
		#no allow list specified, bind all devices
		return 0
	fi

	for i in $PCI_WHITELIST; do
	for i in $PCI_ALLOWED; do
		if [ "$i" == "$1" ]; then
			return 0
		fi
@@ -135,7 +135,7 @@ iter_all_pci_sysfs() {
	fi
}

# This function will ignore PCI PCI_WHITELIST and PCI_BLACKLIST
# This function will ignore PCI PCI_ALLOWED and PCI_BLOCKED
function iter_all_pci_class_code() {
	local class
	local subclass
@@ -167,7 +167,7 @@ function iter_all_pci_class_code() {
	fi
}

# This function will ignore PCI PCI_WHITELIST and PCI_BLACKLIST
# This function will ignore PCI PCI_ALLOWED and PCI_BLOCKED
function iter_all_pci_dev_id() {
	local ven_id
	local dev_id
@@ -199,7 +199,7 @@ function iter_pci_dev_id() {
	done
}

# This function will filter out PCI devices using PCI_WHITELIST and PCI_BLACKLIST
# This function will filter out PCI devices using PCI_ALLOWED and PCI_BLOCKED
# See function pci_can_use()
function iter_pci_class_code() {
	local bdf=""
@@ -213,7 +213,7 @@ function iter_pci_class_code() {

function nvme_in_userspace() {
	# Check used drivers. If it's not vfio-pci or uio-pci-generic
	# then most likely PCI_WHITELIST option was used for setup.sh
	# then most likely PCI_ALLOWED option was used for setup.sh
	# and we do not want to use that disk.

	local bdf bdfs
+13 −13
Original line number Diff line number Diff line
@@ -59,16 +59,16 @@ function usage() {
	echo "                  setting is used."
	echo "CLEAR_HUGE        If set to 'yes', the attempt to remove hugepages from all nodes will"
	echo "                  be made prior to allocation".
	echo "PCI_WHITELIST"
	echo "PCI_BLACKLIST     Whitespace separated list of PCI devices (NVMe, I/OAT, VMD, Virtio)."
	echo "PCI_ALLOWED"
	echo "PCI_BLOCKED       Whitespace separated list of PCI devices (NVMe, I/OAT, VMD, Virtio)."
	echo "                  Each device must be specified as a full PCI address."
	echo "                  E.g. PCI_WHITELIST=\"0000:01:00.0 0000:02:00.0\""
	echo "                  To blacklist all PCI devices use a non-valid address."
	echo "                  E.g. PCI_WHITELIST=\"none\""
	echo "                  If PCI_WHITELIST and PCI_BLACKLIST are empty or unset, all PCI devices"
	echo "                  E.g. PCI_ALLOWED=\"0000:01:00.0 0000:02:00.0\""
	echo "                  To block all PCI devices use a non-valid address."
	echo "                  E.g. PCI_BLOCKED=\"none\""
	echo "                  If PCI_ALLOWED and PCI_BLOCKED are empty or unset, all PCI devices"
	echo "                  will be bound."
	echo "                  Each device in PCI_BLACKLIST will be ignored (driver won't be changed)."
	echo "                  PCI_BLACKLIST has precedence over PCI_WHITELIST."
	echo "                  Each device in PCI_BLOCKED will be ignored (driver won't be changed)."
	echo "                  PCI_BLOCKED has precedence over PCI_ALLOWED."
	echo "TARGET_USER       User that will own hugepage mountpoint directory and vfio groups."
	echo "                  By default the current user will be used."
	echo "DRIVER_OVERRIDE   Disable automatic vfio-pci/uio_pci_generic selection and forcefully"
@@ -235,7 +235,7 @@ function collect_devices() {
					fi
				fi
				if [[ $dev_type == vmd ]]; then
					if [[ $PCI_WHITELIST != *"$bdf"* ]]; then
					if [[ $PCI_ALLOWED != *"$bdf"* ]]; then
						pci_dev_echo "$bdf" "Skipping not allowed VMD controller at $bdf"
						in_use=1
					fi
@@ -717,15 +717,15 @@ if [ -z "$mode" ]; then
fi

: ${HUGEMEM:=2048}
: ${PCI_WHITELIST:=""}
: ${PCI_BLACKLIST:=""}
: ${PCI_ALLOWED:=""}
: ${PCI_BLOCKED:=""}

if [ -n "$NVME_WHITELIST" ]; then
	PCI_WHITELIST="$PCI_WHITELIST $NVME_WHITELIST"
	PCI_ALLOWED="$PCI_ALLOWED $NVME_WHITELIST"
fi

if [ -n "$SKIP_PCI" ]; then
	PCI_WHITELIST="none"
	PCI_ALLOWED="none"
fi

if [ -z "$TARGET_USER" ]; then
+2 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ set -e
SPDK_DIR=$1

# Skip all pci devices. These tests don't rely on them.
sudo PCI_WHITELIST="NONE" HUGEMEM="$HUGEMEM" $SPDK_DIR/scripts/setup.sh
sudo PCI_ALLOWED="NONE" HUGEMEM="$HUGEMEM" $SPDK_DIR/scripts/setup.sh

make -C $SPDK_DIR clean
$SPDK_DIR/configure --with-shared --without-isal --without-ocf --disable-asan
@@ -61,4 +61,4 @@ run_test "external_run_tc6" $test_root/hello_world/hello_bdev --json $test_root/
make -C $test_root clean
make -C $SPDK_DIR -j$(nproc) clean

sudo PCI_WHITELIST="NONE" HUGEMEM="$HUGEMEM" $SPDK_DIR/scripts/setup.sh reset
sudo PCI_ALLOWED="NONE" HUGEMEM="$HUGEMEM" $SPDK_DIR/scripts/setup.sh reset
Loading