Spdk/test/nvmf/target/nvmf_vfio_user.sh
paul luse eb53c23236 add (c) and SPDX header to bash files as needed
per Intel policy to include file commit date using git cmd
below.  The policy does not apply to non-Intel (C) notices.

git log --follow -C90% --format=%ad --date default <file> | tail -1

and then pull just the year from the result.

Intel copyrights were not added to files where Intel either had
no contribution ot the contribution lacked substance (ie license
header updates, formatting changes, etc)

For intel copyrights added, --follow and -C95% were used.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: I2ef86976095b88a9bf5b1003e59f3943cd6bbe4c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15209
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-29 08:27:51 +00:00

98 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2020 Intel Corporation
# All rights reserved.
#
testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../../..)
nvmeappdir=$(readlink -f $rootdir/test/nvme)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/nvmf/common.sh
MALLOC_BDEV_SIZE=64
MALLOC_BLOCK_SIZE=512
NUM_DEVICES=2
rpc_py="$rootdir/scripts/rpc.py"
export TEST_TRANSPORT=VFIOUSER
function aer_vfio_user() {
local traddr=$1
local subnqn=$2
local malloc_num=Malloc$(($3 + NUM_DEVICES))
$rpc_py nvmf_get_subsystems
AER_TOUCH_FILE=/tmp/aer_touch_file
# Namespace Attribute Notice Tests
$rootdir/test/nvme/aer/aer -r "\
trtype:$TEST_TRANSPORT \
traddr:$traddr \
subnqn:$subnqn" -n $NUM_DEVICES -g -t $AER_TOUCH_FILE &
aerpid=$!
# Waiting for aer start to work
waitforfile $AER_TOUCH_FILE
rm -f $AER_TOUCH_FILE
# Add a new namespace
$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE --name $malloc_num
$rpc_py nvmf_subsystem_add_ns $subnqn $malloc_num -n $NUM_DEVICES
$rpc_py nvmf_get_subsystems
wait $aerpid
}
rm -rf /var/run/vfio-user
# Start the target
"${NVMF_APP[@]}" -m '[0,1,2,3]' &
nvmfpid=$!
echo "Process pid: $nvmfpid"
trap 'killprocess $nvmfpid; exit 1' SIGINT SIGTERM EXIT
waitforlisten $nvmfpid
sleep 1
$rpc_py nvmf_create_transport -t $TEST_TRANSPORT
mkdir -p /var/run/vfio-user
for i in $(seq 1 $NUM_DEVICES); do
mkdir -p /var/run/vfio-user/domain/vfio-user$i/$i
$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc$i
$rpc_py nvmf_create_subsystem nqn.2019-07.io.spdk:cnode$i -a -s SPDK$i
$rpc_py nvmf_subsystem_add_ns nqn.2019-07.io.spdk:cnode$i Malloc$i
$rpc_py nvmf_subsystem_add_listener nqn.2019-07.io.spdk:cnode$i -t $TEST_TRANSPORT -a "/var/run/vfio-user/domain/vfio-user$i/$i" -s 0
done
for i in $(seq 1 $NUM_DEVICES); do
test_traddr=/var/run/vfio-user/domain/vfio-user$i/$i
test_subnqn=nqn.2019-07.io.spdk:cnode$i
$SPDK_EXAMPLE_DIR/identify -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn" -g -L nvme -L nvme_vfio -L vfio_pci
sleep 1
$SPDK_EXAMPLE_DIR/perf -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn" -s 256 -g -q 128 -o 4096 -w read -t 5 -c 0x2
sleep 1
$SPDK_EXAMPLE_DIR/perf -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn" -s 256 -g -q 128 -o 4096 -w write -t 5 -c 0x2
sleep 1
$SPDK_EXAMPLE_DIR/reconnect -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn" -g -q 32 -o 4096 -w randrw -M 50 -t 5 -c 0xE
sleep 1
$SPDK_EXAMPLE_DIR/arbitration -t 3 -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn" -d 256 -g
sleep 1
$SPDK_EXAMPLE_DIR/hello_world -d 256 -g -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn"
sleep 1
$nvmeappdir/overhead/overhead -o 4096 -t 1 -H -g -d 256 -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn"
sleep 1
aer_vfio_user $test_traddr $test_subnqn $i
sleep 1
done
killprocess $nvmfpid
rm -rf /var/run/vfio-user
trap - SIGINT SIGTERM EXIT