diff --git a/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh b/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh index a141e486c..d77f97225 100755 --- a/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh +++ b/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh @@ -8,7 +8,9 @@ source $rootdir/scripts/autotest_common.sh source $rootdir/test/nvmf/common.sh source $rootdir/test/iscsi_tgt/common.sh -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index 8b379d481..c39cf63c9 100755 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -3,7 +3,6 @@ NVMF_PORT=4420 NVMF_IP_PREFIX="192.168.100" NVMF_IP_LEAST_ADDR=8 -NVMF_FIRST_TARGET_IP=$NVMF_IP_PREFIX.$NVMF_IP_LEAST_ADDR RPC_PORT=5260 if [ -z "$NVMF_APP" ]; then @@ -88,6 +87,16 @@ function allocate_nic_ips() done } +function get_available_rdma_ips() +{ + nic_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}' + done + done +} + function nvmfcleanup() { sync @@ -100,8 +109,3 @@ function rdma_device_init() detect_rdma_nics allocate_nic_ips } - -function rdma_nic_available() -{ - ifconfig | grep -q $NVMF_IP_PREFIX -} diff --git a/test/nvmf/discovery/discovery.sh b/test/nvmf/discovery/discovery.sh index a65870468..f482e0857 100755 --- a/test/nvmf/discovery/discovery.sh +++ b/test/nvmf/discovery/discovery.sh @@ -17,7 +17,9 @@ if ! hash nvme; then exit 0 fi -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/filesystem/filesystem.sh b/test/nvmf/filesystem/filesystem.sh index 76cb90225..43a491ac7 100755 --- a/test/nvmf/filesystem/filesystem.sh +++ b/test/nvmf/filesystem/filesystem.sh @@ -12,7 +12,9 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/fio/fio.sh b/test/nvmf/fio/fio.sh index 4e4759b47..a1b5b6a76 100755 --- a/test/nvmf/fio/fio.sh +++ b/test/nvmf/fio/fio.sh @@ -12,7 +12,9 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/host/aer.sh b/test/nvmf/host/aer.sh index 6a3277d95..45876cb43 100755 --- a/test/nvmf/host/aer.sh +++ b/test/nvmf/host/aer.sh @@ -9,9 +9,11 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then - echo "no NIC for nvmf test" - exit 0 +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then + echo "no NIC for nvmf test" + exit 0 fi timing_enter aer diff --git a/test/nvmf/host/fio.sh b/test/nvmf/host/fio.sh index c97d98c2d..9a02fa2f8 100755 --- a/test/nvmf/host/fio.sh +++ b/test/nvmf/host/fio.sh @@ -9,9 +9,11 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then - echo "no NIC for nvmf test" - exit 0 +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then + echo "no NIC for nvmf test" + exit 0 fi if [ ! -d /usr/src/fio ]; then diff --git a/test/nvmf/host/identify.sh b/test/nvmf/host/identify.sh index 51daabe39..73a3434e4 100755 --- a/test/nvmf/host/identify.sh +++ b/test/nvmf/host/identify.sh @@ -12,11 +12,12 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then - echo "no NIC for nvmf test" - exit 0 +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then + echo "no NIC for nvmf test" + exit 0 fi - timing_enter identify timing_enter start_nvmf_tgt diff --git a/test/nvmf/host/identify_kernel_nvmf.sh b/test/nvmf/host/identify_kernel_nvmf.sh index 207f62f48..e98586c48 100755 --- a/test/nvmf/host/identify_kernel_nvmf.sh +++ b/test/nvmf/host/identify_kernel_nvmf.sh @@ -7,7 +7,9 @@ source $rootdir/test/nvmf/common.sh set -e -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/host/perf.sh b/test/nvmf/host/perf.sh index bb20d0d67..14ce5a3fb 100755 --- a/test/nvmf/host/perf.sh +++ b/test/nvmf/host/perf.sh @@ -12,9 +12,11 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then - echo "no NIC for nvmf test" - exit 0 +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then + echo "no NIC for nvmf test" + exit 0 fi timing_enter perf diff --git a/test/nvmf/multiconnection/multiconnection.sh b/test/nvmf/multiconnection/multiconnection.sh index b91388dd4..87456bb62 100755 --- a/test/nvmf/multiconnection/multiconnection.sh +++ b/test/nvmf/multiconnection/multiconnection.sh @@ -12,7 +12,9 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/nvme_cli/nvme_cli.sh b/test/nvmf/nvme_cli/nvme_cli.sh index 86aa72dc5..733f161d5 100755 --- a/test/nvmf/nvme_cli/nvme_cli.sh +++ b/test/nvmf/nvme_cli/nvme_cli.sh @@ -12,7 +12,9 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/rpc/rpc.sh b/test/nvmf/rpc/rpc.sh index 5a7026efc..66c2233d6 100755 --- a/test/nvmf/rpc/rpc.sh +++ b/test/nvmf/rpc/rpc.sh @@ -9,7 +9,9 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi diff --git a/test/nvmf/shutdown/shutdown.sh b/test/nvmf/shutdown/shutdown.sh index 48723c48a..3c9095c83 100755 --- a/test/nvmf/shutdown/shutdown.sh +++ b/test/nvmf/shutdown/shutdown.sh @@ -12,7 +12,9 @@ rpc_py="python $rootdir/scripts/rpc.py" set -e -if ! rdma_nic_available; then +RDMA_IP_LIST=$(get_available_rdma_ips) +NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1) +if [ -z $NVMF_FIRST_TARGET_IP ]; then echo "no NIC for nvmf test" exit 0 fi