test/nvmf: try to initialize only available RDMA NICs

Instead of rushing and probing all drivers for all NICs,
first try to check which RDMA drivers are already loaded.
Try only to use these NICs which drivers are already
available. This makes it easier to select which NIC
vendor will be used in test, as not all NICs will be
listed under /sys/class/infiniband (even if physically
present in system).

If for some reason a preloaded driver is detected, but
no physical NIC is seen in lspci - fall back to "old way"
and try to all NICs known to us.

Also includes code change to following if block, just
for style consistency in function.

Change-Id: Idc5756b5d4927b0ff11b5a37ed3729995f5c8f8a
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5948
Community-CI: Broadcom CI
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Karol Latecki 2021-01-15 19:26:17 +01:00 committed by Tomasz Zawadzki
parent 40597c9b95
commit 45866e50c3

View File

@ -71,20 +71,57 @@ function detect_nics_and_probe_drivers() {
fi
}
function pci_nics_switch() {
local driver=$1
local -a driver_args=()
driver_args+=("Mellanox ConnectX-4 mlx5_core mlx5_ib")
driver_args+=("Mellanox ConnectX-5 mlx5_core mlx5_ib")
driver_args+=("Intel X722 i40e i40iw")
driver_args+=("Chelsio \"Unified Wire\" cxgb4 iw_cxgb4")
case $driver in
mlx5_ib)
detect_nics_and_probe_drivers ${driver_args[0]}
detect_nics_and_probe_drivers ${driver_args[1]}
;;
i40iw)
detect_nics_and_probe_drivers ${driver_args[2]}
;;
iw_cxgb4)
detect_nics_and_probe_drivers ${driver_args[3]}
;;
*)
for d in "${driver_args[@]}"; do
detect_nics_and_probe_drivers $d
done
;;
esac
}
function detect_pci_nics() {
if ! hash lspci; then
return 0
fi
detect_nics_and_probe_drivers "Mellanox" "ConnectX-4" "mlx5_core" "mlx5_ib"
detect_nics_and_probe_drivers "Mellanox" "ConnectX-5" "mlx5_core" "mlx5_ib"
detect_nics_and_probe_drivers "Intel" "X722" "i40e" "i40iw"
detect_nics_and_probe_drivers "Chelsio" "Unified Wire" "cxgb4" "iw_cxgb4"
local rdma_drivers="mlx5_ib|irdma|i40iw|iw_cxgb4"
local found_drivers
if [ "$have_pci_nics" -eq "0" ]; then
return 0
fi
# Try to find RDMA drivers which are already loded and try to
# use only it's associated NICs, without probing all drivers.
found_drivers=$(lsmod | grep -Eo $rdma_drivers | sort -u)
for d in $found_drivers; do
pci_nics_switch $d
done
# In case lsmod reported driver, but lspci does not report
# physical NICs - fall back to old approach any try to
# probe all compatible NICs.
((have_pci_nics == 0)) && pci_nics_switch "default"
# Use softroce if everything else failed.
((have_pci_nics == 0)) && return 0
# Provide time for drivers to properly load.
sleep 5