diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index 15ba89d5a..e5f89609f 100755 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -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 - - # dump configuration for debug log - ifconfig $nic_name let count=$count+1 - done + fi + # dump configuration for debug log + ifconfig $nic_name 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 +} diff --git a/test/nvmf/nvmf.sh b/test/nvmf/nvmf.sh index 0f1006539..93e536bc1 100755 --- a/test/nvmf/nvmf.sh +++ b/test/nvmf/nvmf.sh @@ -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