From 5dff03721be73945316ac39d6d444df48ab267b5 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 4 Mar 2019 09:16:19 -0700 Subject: [PATCH] test/nvmf: detect mlx_4 and mlx_5 NICS into 2 funcs This helps us simplify the detection of Mellanox NICS and paves the way for a more modular detection scheme for PCIe connected NICs. Change-Id: I93f16f469c569977c43d6e20fd4616299fa8c723 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446965 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- test/nvmf/common.sh | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index 0294017ff..ab41ebb2b 100755 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -42,9 +42,25 @@ function detect_soft_roce_nics() fi } -function detect_mellanox_nics() + +function detect_mlx_5_nics() { - nvmf_nic_bdfs=`lspci | grep Ethernet | grep Mellanox | awk -F ' ' '{print "0000:"$1}'` + nvmf_nic_bdfs=`lspci | grep Ethernet | grep Mellanox | grep ConnectX-5 | awk -F ' ' '{print "0000:"$1}'` + mlx_core_driver="mlx5_core" + mlx_ib_driver="mlx5_ib" + + if [ -z "$nvmf_nic_bdfs" ]; then + echo "No NICs" + return 0 + fi + + modprobe $mlx_core_driver + modprobe $mlx_ib_driver +} + +function detect_mlx_4_nics() +{ + nvmf_nic_bdfs=`lspci | grep Ethernet | grep Mellanox | grep ConnectX-4 | awk -F ' ' '{print "0000:"$1}'` mlx_core_driver="mlx4_core" mlx_ib_driver="mlx4_ib" mlx_en_driver="mlx4_en" @@ -54,23 +70,9 @@ function detect_mellanox_nics() return 0 fi - # for nvmf target loopback test, suppose we only have one type of card. - for nvmf_nic_bdf in $nvmf_nic_bdfs - do - result=`lspci -vvv -s $nvmf_nic_bdf | grep 'Kernel modules' | awk -F ' ' '{print $3}'` - if [ "$result" == "mlx5_core" ]; then - mlx_core_driver="mlx5_core" - mlx_ib_driver="mlx5_ib" - mlx_en_driver="" - fi - break; - done - modprobe $mlx_core_driver modprobe $mlx_ib_driver - if [ -n "$mlx_en_driver" ]; then - modprobe $mlx_en_driver - fi + modprobe $mlx_en_driver } function detect_pci_nics() @@ -81,9 +83,10 @@ function detect_pci_nics() return 0 fi - mellanox_nics=$(detect_mellanox_nics) + mlx_4_nics=$(detect_mlx_4_nics) + mlx_5_nics=$(detect_mlx_5_nics) - if [ "$mellanox_nics" == "No NICs" ]; then + if [ "$mlx_4_nics" == "No NICs" -a "$mlx_5_nics" == "No NICs" ]; then echo "No NICs" return 0 fi