Spdk/test/setup/driver.sh
paul luse eb53c23236 add (c) and SPDX header to bash files as needed
per Intel policy to include file commit date using git cmd
below.  The policy does not apply to non-Intel (C) notices.

git log --follow -C90% --format=%ad --date default <file> | tail -1

and then pull just the year from the result.

Intel copyrights were not added to files where Intel either had
no contribution ot the contribution lacked substance (ie license
header updates, formatting changes, etc)

For intel copyrights added, --follow and -C95% were used.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: I2ef86976095b88a9bf5b1003e59f3943cd6bbe4c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15209
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-29 08:27:51 +00:00

83 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2020 Intel Corporation
# All rights reserved.
#
testdir=$(readlink -f "$(dirname "$0")")
rootdir=$(readlink -f "$testdir/../../")
source "$testdir/common.sh"
shopt -s nullglob extglob
dep() { modprobe --show-depends "$1"; }
mod() { [[ $(dep "$1") == *".ko"* ]]; }
bui() { [[ $(dep "$1") == "builtin $1" ]]; }
is_driver() { mod "$1" || bui "$1"; }
uio() {
is_driver uio_pci_generic
}
vfio() {
local iommu_grups
local unsafe_vfio
[[ -e /sys/module/vfio/parameters/enable_unsafe_noiommu_mode ]] \
&& unsafe_vfio=$(< /sys/module/vfio/parameters/enable_unsafe_noiommu_mode)
iommu_groups=(/sys/kernel/iommu_groups/*)
if ((${#iommu_groups[@]} > 0)) || [[ $unsafe_vfio == Y ]]; then
is_driver vfio_pci && return 0
fi
return 1
}
igb_uio() {
is_driver igb_uio
}
pick_driver() {
if vfio; then
echo "vfio-pci"
elif uio; then
# Consider special case for broken uio_pci_generic driver
if igb_uio; then
echo "@(uio_pci_generic|igb_uio)"
else
echo "uio_pci_generic"
fi
elif igb_uio; then
echo "igb_uio"
else
echo "No valid driver found"
fi
}
guess_driver() {
local driver setup_driver marker
local fail=0
driver=$(pick_driver)
if [[ $driver == "No valid driver found" ]]; then
[[ $(setup output config) == "$driver"* ]]
return 0
fi
echo "Looking for driver=$driver"
while read -r _ _ _ _ marker setup_driver; do
[[ $marker == "->" ]] || continue
# Allow for more open matching
# shellcheck disable=SC2053
[[ $setup_driver == $driver ]] || fail=1
done < <(setup output config)
((fail == 0))
setup reset
}
setup reset
run_test "guess_driver" "guess_driver"