test/nvmf: make common function for probing pci NICs

Change-Id: I9368a44ebfec54ab705bd371ffd45de1c0bce5ac
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446967
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Seth Howell 2019-03-04 09:50:07 -07:00 committed by Changpeng Liu
parent 9f03beea38
commit 1e867a8966

View File

@ -45,39 +45,32 @@ function detect_soft_roce_nics()
}
function detect_mlx_5_nics()
# args 1 and 2 represent the grep filters for finding our NICS.
# subsequent args are all drivers that should be loaded if we find these NICs.
# Those drivers should be supplied in the correct order.
function detect_nics_and_probe_drivers()
{
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"
NIC_VENDOR="$1"
NIC_CLASS="$2"
if [ -z "$nvmf_nic_bdfs" ]; then
echo "No NICs"
return 0
fi
have_pci_nics=1
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"
nvmf_nic_bdfs=`lspci | grep Ethernet | grep "$NIC_VENDOR" | grep "$NIC_CLASS" | awk -F ' ' '{print "0000:"$1}'`
if [ -z "$nvmf_nic_bdfs" ]; then
return 0
fi
have_pci_nics=1
modprobe $mlx_core_driver
modprobe $mlx_ib_driver
modprobe $mlx_en_driver
if [ $# -ge 2 ]; then
# shift out the first two positional arguments.
shift 2
# Iterate through the remaining arguments.
for i; do
modprobe "$i"
done
fi
}
function detect_pci_nics()
{
@ -85,8 +78,8 @@ function detect_pci_nics()
return 0
fi
detect_mlx_4_nics
detect_mlx_5_nics
detect_nics_and_probe_drivers "Mellanox" "ConnectX-4" "mlx4_core" "mlx4_ib" "mlx4_en"
detect_nics_and_probe_drivers "Mellanox" "ConnectX-5" "mlx5_core" "mlx5_ib"
if [ "$have_pci_nics" -eq "0" ]; then
return 0