Commit 36fb7fcd authored by Seth Howell's avatar Seth Howell Committed by Daniel Verkamp
Browse files

test/nvmf: configure all nics when running NVMF tests.



Change-Id: Ia40f0817320ac7f12312299633a7c40136c2e806
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/371219


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 80c91e4e
Loading
Loading
Loading
Loading
+38 −17
Original line number Diff line number Diff line
@@ -33,10 +33,14 @@ function load_ib_rdma_modules()
function detect_soft_roce_nics()
{
	if hash rxe_cfg; then
		interface="$(ifconfig | grep "RUNNING" -m 1 | awk '{print $1}' | sed s/://)"
		rxe_cfg add $interface
		rxe_cfg start
		export SOFT_ROCE=true
		rdma_nics=$(get_rdma_if_list)
		all_nics=$(ifconfig -s | awk '{print $1}')
		all_nics=("${all_nics[@]/"Iface"}")
		non_rdma_nics=$(echo "$rdma_nics $all_nics" | sort | uniq -u)
		for nic in $non_rdma_nics; do
			rxe_cfg add $nic || true
		done
	fi
}

@@ -86,34 +90,40 @@ function detect_rdma_nics()

function allocate_nic_ips()
{
	# If a Soft-RoCE nic was allocated, it already has an ip address atached to it
	# and we use it in preference to any other RDMA nics attached to the device.
	if [ $SOFT_ROCE == true ]; then
		return 0
	fi

	let count=$NVMF_IP_LEAST_ADDR
	for nic_type in `ls /sys/class/infiniband`; do
		for nic_name in `ls /sys/class/infiniband/${nic_type}/device/net`; do
	for nic_name in $get_rdma_if_list; do
		ip="$(get_ip_address $nic_name)"
		if [ -z $ip ]; then
			ifconfig $nic_name $NVMF_IP_PREFIX.$count netmask 255.255.255.0 up

			let count=$count+1
		fi
		# dump configuration for debug log
		ifconfig $nic_name
			let count=$count+1
		done
	done
}

function get_available_rdma_ips()
{
	nic_list=""
	for nic_name in $get_rdma_if_list; do
		ifconfig $nic_name | grep "inet " | awk '{print $2}'
	done
}

function get_rdma_if_list()
{
	for nic_type in `ls /sys/class/infiniband`; do
		for nic_name in `ls /sys/class/infiniband/${nic_type}/device/net`; do
			ifconfig $nic_name | grep "inet " | awk '{print $2}'
			echo "$nic_name"
		done
	done
}

function get_ip_address()
{
	interface=$1
	ifconfig $interface | grep "inet " | awk '{print $2}'
}

function nvmfcleanup()
{
	sync
@@ -126,3 +136,14 @@ function rdma_device_init()
	detect_rdma_nics
	allocate_nic_ips
}

function revert_soft_roce()
{
	if hash rxe_cfg; then
		interfaces="$(ifconfig -s | awk '{print $1}')"
		for interface in $interfaces; do
			rxe_cfg remove $interface || true
		done
		rxe_cfg stop || true
	fi
}
+1 −0
Original line number Diff line number Diff line
@@ -50,4 +50,5 @@ kill_stub
# TODO: enable nvme device detachment for multi-process so that
#  we can use the stub for this test
run_test test/nvmf/rpc/rpc.sh
revert_soft_roce
timing_exit nvmf_tgt