setup.sh: move pci_can_bind function to common.sh

Change-Id: I1c3ba13c39ef0d06d70e6e262bdc08c76a7614e0
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/443766 (master)
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448426
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Pawel Wodkowski 2019-02-07 13:28:49 +01:00 committed by Darek Stojaczyk
parent 42f24e153a
commit a80c73c002
2 changed files with 28 additions and 20 deletions

View File

@ -1,5 +1,33 @@
# Common shell utility functions
# Check if PCI device is on PCI_WHITELIST and not on PCI_BLACKLIST
# Env:
# if PCI_WHITELIST is empty assume device is whitelistened
# if PCI_BLACKLIST is empty assume device is NOT blacklistened
# Params:
# $1 - PCI BDF
function pci_can_bind() {
local i
# The '\ ' part is important
if [[ " $PCI_BLACKLIST " =~ \ $1\ ]] ; then
return 1
fi
if [[ -z "$PCI_WHITELIST" ]]; then
#no whitelist specified, bind all devices
return 0
fi
for i in $PCI_WHITELIST; do
if [ "$i" == "$1" ] ; then
return 0
fi
done
return 1
}
function iter_pci_class_code() {
local class="$(printf %02x $((0x$1)))"
local subclass="$(printf %02x $((0x$2)))"

View File

@ -77,26 +77,6 @@ function check_for_driver {
return 0
}
function pci_can_bind() {
# The '\ ' part is important
if [[ " $PCI_BLACKLIST " =~ \ $1\ ]] ; then
return 1
fi
if [[ -z "$PCI_WHITELIST" ]]; then
#no whitelist specified, bind all devices
return 0
fi
for i in $PCI_WHITELIST; do
if [ "$i" == "$1" ] ; then
return 0
fi
done
return 1
}
function pci_dev_echo() {
local bdf="$1"
local vendor="$(cat /sys/bus/pci/devices/$bdf/vendor)"