From c8bcedf4df048967e38391d1b08c33d521fdea7a Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 11 Feb 2019 12:50:08 -0700 Subject: [PATCH] setup.sh: enable using the igb_uio driver On some platforms, especially AWS, uio_pci_generic is not readily available, and we don't have access to an IOMMU, so using the DPDK igb_uio driver is a valid workaround. Change-Id: Ic96776f925d9bbbcab625f5adb7642ca6bd4033d Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/444122 Reviewed-by: Pawel Wodkowski Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- scripts/setup.sh | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 6be3e4c0a..9998efae5 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -55,7 +55,7 @@ function usage() echo " By default the current user will be used." echo "DRIVER_OVERRIDE Disable automatic vfio-pci/uio_pci_generic selection and forcefully" echo " bind devices to the given driver." - echo " E.g. DRIVER_OVERRIDE=uio_pci_generic or DRIVER_OVERRIDE=vfio-pci" + echo " E.g. DRIVER_OVERRIDE=uio_pci_generic or DRIVER_OVERRIDE=/home/public/dpdk/build/kmod/igb_uio.ko" exit 0 } @@ -167,22 +167,40 @@ function get_virtio_names_from_bdf { } function configure_linux_pci { - if [ -z "${DRIVER_OVERRIDE}" ]; then - driver_name=vfio-pci - if [ -z "$(ls /sys/kernel/iommu_groups)" ]; then - # No IOMMU. If no-IOMMU mode vfio is not present, then use uio. - if ! [ -e /sys/module/vfio/parameters/enable_unsafe_noiommu_mode ] || - ! [ "$(cat /sys/module/vfio/parameters/enable_unsafe_noiommu_mode)" == "Y" ] - then - driver_name=uio_pci_generic - fi + local driver_path="" + driver_name="" + if [[ -n "${DRIVER_OVERRIDE}" ]]; then + driver_path="${DRIVER_OVERRIDE%/*}" + driver_name="${DRIVER_OVERRIDE##*/}" + # path = name -> there is no path + if [[ "$driver_path" = "$driver_name" ]]; then + driver_path="" fi + elif [[ -n "$(ls /sys/kernel/iommu_groups)" || \ + (-e /sys/module/vfio/parameters/enable_unsafe_noiommu_mode && \ + "$(cat /sys/module/vfio/parameters/enable_unsafe_noiommu_mode)" == "Y") ]]; then + driver_name=vfio-pci + elif modinfo uio_pci_generic >/dev/null 2>&1; then + driver_name=uio_pci_generic + elif [[ -r "$rootdir/dpdk/build/kmod/igb_uio.ko" ]]; then + driver_path="$rootdir/dpdk/build/kmod/igb_uio.ko" + driver_name="igb_uio" + modprobe uio + echo "WARNING: uio_pci_generic not detected - using $driver_name" else - driver_name="${DRIVER_OVERRIDE}" + echo "No valid drivers found [vfio-pci, uio_pci_generic, igb_uio]. Please either enable the vfio-pci or uio_pci_generic" + echo "kernel modules, or have SPDK build the igb_uio driver by running ./configure --with-igb-uio-driver and recompiling." + return 1 + fi + + # modprobe assumes the directory of the module. If the user passes in a path, we should use insmod + if [[ -n "$driver_path" ]]; then + insmod $driver_path || true + else + modprobe $driver_name fi # NVMe - modprobe $driver_name for bdf in $(iter_all_pci_class_code 01 08 02); do blkname='' get_nvme_name_from_bdf "$bdf" blkname