setup.sh: Add support for NVMe whitelisting

In some cases we may not want to assign all PCIe NVMe controllers in a
system to SPDK. Add a new input to the setup.sh script called
NVME_WHITELIST which whitelists (via PCIe slot ID) the NVMe
controllers you wish to add to SPDK.

If the NVME_WHITELIST input argument is not defined then all PCIe NVMe
controllers will be added. The values in the whitelist whould be
white-space seperated and the entire list should be enclosed in double
quotes ("").

To blacklist all PCIe NVMe devices use a non-valid PCIe slot ID
(e.g. the string "none" would work very well).

Examples:

NVME_WHITELIST="0000:02:00.0" ./setup.sh
NVME_WHITELIST="0000:08:00.0 0000:06:00.1" ./setup.sh
NVME_WHITELIST="none" ./setup.sh

Change-Id: If6ebb04307180cbac11fc41cd9a70749640bc598
Signed-off-by: Stephen Bates <sbates@raithlin.com>
Reviewed-on: https://review.gerrithub.io/394303
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Stephen Bates 2018-01-10 16:14:39 -07:00 committed by Jim Harris
parent 0e91725631
commit 5c13f5ae6d

View File

@ -5,6 +5,16 @@ set -e
rootdir=$(readlink -f $(dirname $0))/..
source "$rootdir/scripts/common.sh"
function nvme_whitelist_contains() {
for i in ${NVME_WHITELIST[@]}
do
if [ "$i" == "$1" ] ; then
return 1
fi
done
return 0
}
function linux_bind_driver() {
bdf="$1"
driver_name="$2"
@ -98,6 +108,10 @@ function configure_linux_pci {
for bdf in $(iter_pci_class_code 01 08 02); do
blkname=''
get_nvme_name_from_bdf "$bdf" blkname
if [[ ${#NVME_WHITELIST[@]} != 0 ]] && nvme_whitelist_contains $bdf == "0" ; then
echo "Skipping un-whitelisted NVMe controller $blkname ($bdf)"
continue
fi
if [ "$blkname" != "" ]; then
mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
else
@ -378,6 +392,8 @@ fi
: ${HUGEMEM:=2048}
: ${SKIP_PCI:=0}
: ${NVME_WHITELIST:=""}
declare -a NVME_WHITELIST=(${NVME_WHITELIST})
if [ `uname` = Linux ]; then
HUGEPGSZ=$(( `grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'` ))