Commit 7014f640 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

scripts/setup: Add support for $DEV_TYPE



This var should hold a pattern matching any of the supported types.
In case of a match, only given type of devices would be acted on.
extglob patterns are allowed as well for more flexibility, e.g.:

  $ DEV_TYPE=@(nvme|virtio) ./scripts/setup.sh status

Change-Id: Ia526fdafcd6456555b5dde5ddce82021426c1400
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22583


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent bf3ddff0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -429,6 +429,7 @@ get_spdk_gpt() {
}

map_supported_devices() {
	local type=${1^^}
	local ids dev_types dev_type dev_id bdf bdfs vmd _vmd

	local -gA nvme_d
@@ -449,6 +450,7 @@ map_supported_devices() {
	((${#pci_bus_cache[@]} == 0)) && cache_pci_bus

	while read -r _ dev_type dev_id; do
		[[ $dev_type == *$type* ]] || continue
		bdfs=(${pci_bus_cache["0x8086:$dev_id"]})
		[[ $dev_type == *NVME* ]] && bdfs=(${pci_bus_cache["$dev_id"]})
		[[ $dev_type == *VIRT* ]] && bdfs=(${pci_bus_cache["0x1af4:$dev_id"]})
+5 −1
Original line number Diff line number Diff line
@@ -89,6 +89,10 @@ function usage() {
	echo "UNBIND_ENTIRE_IOMMU_GROUP"
	echo "                  If set, all devices from nvme's iommu group will be unbound from their drivers."
	echo "                  Use with caution."
	echo "DEV_TYPE"
	echo "                  Perform action only against selected type of devices. Supported:"
	echo "                    IOAT|DSA|IAA|VIRTIO|VMD|NVME."
	echo "                  Default is to select all types."
	exit 0
}

@@ -284,7 +288,7 @@ function get_used_bdf_block_devs() {
function collect_devices() {
	local mode=$1 in_use

	map_supported_devices
	map_supported_devices "$DEV_TYPE"

	for bdf in "${!all_devices_d[@]}"; do
		in_use=0