From 45866e50c3168c2db2bb798fb5d332d018925031 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Fri, 15 Jan 2021 19:26:17 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5948 Community-CI: Broadcom CI Reviewed-by: Aleksey Marchuk Reviewed-by: Tomasz Zawadzki Tested-by: SPDK CI Jenkins --- test/nvmf/common.sh | 51 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index 3c6893796..9b5780809 100644 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -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