scripts/common: Use separate function for nvme driver lookup
Check if given pci address is bound to nvme driver via a separate function - this makes the task of getting list of the nvme devices that can be used in tests a bit easier since we don't have to relay on, e.g., gen_nvme.sh where the extra step to get said devices is to parse the actual config. Change-Id: I1f15f08a3678c0c41b051348af259e225356c340 Signed-off-by: Michal Berger <michalx.berger@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3014 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
eb1f031c88
commit
35babaded1
@ -212,3 +212,28 @@ function iter_pci_class_code() {
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
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
|
||||
# and we do not want to use that disk.
|
||||
|
||||
local bdf bdfs
|
||||
local nvmes
|
||||
|
||||
if [[ -n ${pci_bus_cache["0x010802"]} ]]; then
|
||||
nvmes=(${pci_bus_cache["0x010802"]})
|
||||
else
|
||||
nvmes=($(iter_pci_class_code 01 08 02))
|
||||
fi
|
||||
|
||||
for bdf in "${nvmes[@]}"; do
|
||||
if [[ -e /sys/bus/pci/drivers/nvme/$bdf ]] \
|
||||
|| [[ $(uname -s) == FreeBSD && $(pciconf -l "pci$bdf") == nvme* ]]; then
|
||||
continue
|
||||
fi
|
||||
bdfs+=("$bdf")
|
||||
done
|
||||
((${#bdfs[@]})) || return 1
|
||||
printf '%s\n' "${bdfs[@]}"
|
||||
}
|
||||
|
@ -34,17 +34,7 @@ function create_json_config() {
|
||||
echo '}'
|
||||
}
|
||||
|
||||
bdfs=()
|
||||
# Check used drivers. If it's not vfio-pci or uio-pci-generic
|
||||
# then most likely PCI_WHITELIST option was used for setup.sh
|
||||
# and we do not want to use that disk.
|
||||
for bdf in $(iter_pci_class_code 01 08 02); do
|
||||
if [[ -e /sys/bus/pci/drivers/nvme/$bdf ]] \
|
||||
|| [[ $(uname -s) == FreeBSD && $(pciconf -l "pci$bdf") == nvme* ]]; then
|
||||
continue
|
||||
fi
|
||||
bdfs+=("$bdf")
|
||||
done
|
||||
bdfs=($(nvme_in_userspace))
|
||||
|
||||
if [ "$1" = "--json" ]; then
|
||||
create_json_config
|
||||
|
Loading…
x
Reference in New Issue
Block a user