Commit 1e867a89 authored by Seth Howell's avatar Seth Howell Committed by Changpeng Liu
Browse files

test/nvmf: make common function for probing pci NICs



Change-Id: I9368a44ebfec54ab705bd371ffd45de1c0bce5ac
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446967


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 9f03beea
Loading
Loading
Loading
Loading
+18 −25
Original line number Diff line number Diff line
@@ -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