From 51b5fa857994026ecf32fa7afdddac1b2e3f41cc Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Fri, 21 Aug 2020 12:15:13 +0200 Subject: [PATCH] scripts/setup: Group all devices into respective arrays This is a first patch from a series attempting to merge similar routines used throughout setup.sh. Change-Id: I4c71b88f7556b0e9e2f65a37b8175914022486a4 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3889 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- scripts/setup.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/setup.sh b/scripts/setup.sh index ca271e173..b1889e55a 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -179,6 +179,31 @@ function get_virtio_names_from_bdf() { eval "$2=( " "${virtio_names[@]}" " )" } +function collect_devices() { + # NVMe, IOAT, IDXD, VIRTIO, VMD + + local ids dev_type dev_id bdf bdfs + + ids+="PCI_DEVICE_ID_INTEL_IOAT" + ids+="|PCI_DEVICE_ID_INTEL_IDXD" + ids+="|PCI_DEVICE_ID_VIRTIO" + ids+="|PCI_DEVICE_ID_INTEL_VMD" + ids+="|SPDK_PCI_CLASS_NVME" + + local -gA nvme_d ioat_d idxd_d virtio_d vmd_d all_devices_d + + while read -r _ dev_type dev_id; do + 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"]}) + [[ $dev_type =~ (NVME|IOAT|IDXD|VIRTIO|VMD) ]] + for bdf in "${bdfs[@]}"; do + eval "${BASH_REMATCH[1],,}_d[$bdf]=1" + all_devices_d["$bdf"]=1 + done + done < <(grep -E "$ids" "$rootdir/include/spdk/pci_ids.h") +} + function configure_linux_pci() { local driver_path="" driver_name="" @@ -850,6 +875,7 @@ if [ -z "$TARGET_USER" ]; then fi fi +collect_devices "$mode" if [[ $os == Linux ]]; then HUGEPGSZ=$(($(grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'))) HUGEPGSZ_MB=$((HUGEPGSZ / 1024))