2019-06-27 14:49:26 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
|
|
|
rootdir=$(readlink -f $testdir/../..)
|
|
|
|
source $rootdir/scripts/common.sh
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
|
|
|
|
2019-07-01 11:58:39 +00:00
|
|
|
rpc_py=$rootdir/scripts/rpc.py
|
2020-04-21 14:31:47 +00:00
|
|
|
VMD_WHITELIST=()
|
2019-06-27 14:49:26 +00:00
|
|
|
|
2019-12-04 22:25:07 +00:00
|
|
|
function vmd_identify {
|
|
|
|
for bdf in $pci_devs; do
|
|
|
|
$rootdir/examples/nvme/identify/identify -i 0 -V -r "trtype:PCIe traddr:$bdf"
|
|
|
|
done
|
|
|
|
}
|
2019-06-27 14:49:26 +00:00
|
|
|
|
2019-12-04 22:25:07 +00:00
|
|
|
function vmd_perf {
|
|
|
|
for bdf in $pci_devs; do
|
|
|
|
$rootdir/examples/nvme/perf/perf -q 128 -w read -o 12288 -t 1 -LL -i 0 -V -r "trtype:PCIe traddr:$bdf"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function vmd_fio {
|
2019-06-27 14:49:26 +00:00
|
|
|
PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin
|
|
|
|
for bdf in $pci_devs; do
|
|
|
|
fio_nvme $testdir/config/config.fio --filename="trtype=PCIe traddr=${bdf//:/.} ns=1"
|
|
|
|
done
|
2019-12-04 22:25:07 +00:00
|
|
|
}
|
2019-06-27 14:49:26 +00:00
|
|
|
|
2019-12-04 22:25:07 +00:00
|
|
|
function vmd_bdev_svc {
|
|
|
|
$rootdir/test/app/bdev_svc/bdev_svc --wait-for-rpc & svcpid=$!
|
|
|
|
trap 'killprocess $svcpid; exit 1' SIGINT SIGTERM EXIT
|
2019-07-01 11:58:39 +00:00
|
|
|
|
2019-12-04 22:25:07 +00:00
|
|
|
# Wait until bdev_svc starts
|
|
|
|
waitforlisten $svcpid
|
2019-07-01 11:58:39 +00:00
|
|
|
|
2019-12-04 22:25:07 +00:00
|
|
|
$rpc_py enable_vmd
|
|
|
|
$rpc_py framework_start_init
|
|
|
|
|
|
|
|
for bdf in $pci_devs; do
|
|
|
|
$rpc_py bdev_nvme_attach_controller -b NVMe_$bdf -t PCIe -a $bdf
|
|
|
|
done
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
killprocess $svcpid
|
|
|
|
}
|
|
|
|
|
2020-04-21 14:31:47 +00:00
|
|
|
|
|
|
|
# Re-run setup.sh script and only attach VMD devices to uio/vfio.
|
|
|
|
$rootdir/scripts/setup.sh reset
|
|
|
|
|
|
|
|
vmd_id=$(grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h | awk -F"x" '{print $2}')
|
|
|
|
|
|
|
|
for bdf in $(iter_pci_dev_id 8086 $vmd_id); do
|
|
|
|
if pci_can_use $bdf; then
|
|
|
|
VMD_WHITELIST+=("$bdf")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
PCI_WHITELIST="${VMD_WHITELIST[*]}" $rootdir/scripts/setup.sh
|
|
|
|
|
|
|
|
pci_devs=$($rootdir/app/spdk_lspci/spdk_lspci | grep "NVMe disk behind VMD" | awk '{print $1}')
|
|
|
|
|
|
|
|
if [[ -z "$pci_devs" ]]; then
|
|
|
|
echo "Couldn't find any NVMe device behind a VMD."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-19 23:03:30 +00:00
|
|
|
run_test "vmd_identify" vmd_identify
|
|
|
|
run_test "vmd_hello_world" $rootdir/examples/nvme/hello_world/hello_world -V
|
|
|
|
run_test "vmd_perf" vmd_perf
|
2020-03-02 19:55:44 +00:00
|
|
|
if [[ $CONFIG_FIO_PLUGIN == y ]]; then
|
2019-12-19 23:03:30 +00:00
|
|
|
run_test "vmd_fio" vmd_fio
|
2019-12-04 22:25:07 +00:00
|
|
|
fi
|
2019-07-01 11:58:39 +00:00
|
|
|
|
2019-12-19 23:03:30 +00:00
|
|
|
run_test "vmd_bdev_svc" vmd_bdev_svc
|
2020-04-21 14:31:47 +00:00
|
|
|
|
|
|
|
# Re-run setup.sh again so that other tests may continue
|
|
|
|
$rootdir/scripts/setup.sh reset
|
|
|
|
$rootdir/scripts/setup.sh
|