]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/vmd/vmd.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / test / vmd / vmd.sh
1 #!/usr/bin/env bash
2
3 testdir=$(readlink -f $(dirname $0))
4 rootdir=$(readlink -f $testdir/../..)
5 source $rootdir/scripts/common.sh
6 source $rootdir/test/common/autotest_common.sh
7
8 rpc_py=$rootdir/scripts/rpc.py
9 VMD_WHITELIST=()
10
11 function vmd_identify() {
12 for bdf in $pci_devs; do
13 $SPDK_EXAMPLE_DIR/identify -i 0 -V -r "trtype:PCIe traddr:$bdf"
14 done
15 }
16
17 function vmd_perf() {
18 for bdf in $pci_devs; do
19 $SPDK_EXAMPLE_DIR/perf -q 128 -w read -o 12288 -t 1 -LL -i 0 -V -r "trtype:PCIe traddr:$bdf"
20 done
21 }
22
23 function vmd_fio() {
24 for bdf in $pci_devs; do
25 fio_nvme $testdir/config/config.fio --filename="trtype=PCIe traddr=${bdf//:/.} ns=1"
26 done
27 }
28
29 function vmd_bdev_svc() {
30 $rootdir/test/app/bdev_svc/bdev_svc --wait-for-rpc &
31 svcpid=$!
32 trap 'killprocess $svcpid; exit 1' SIGINT SIGTERM EXIT
33
34 # Wait until bdev_svc starts
35 waitforlisten $svcpid
36
37 $rpc_py enable_vmd
38 $rpc_py framework_start_init
39
40 for bdf in $pci_devs; do
41 $rpc_py bdev_nvme_attach_controller -b NVMe_$bdf -t PCIe -a $bdf
42 done
43
44 trap - SIGINT SIGTERM EXIT
45 killprocess $svcpid
46 }
47
48 # Re-run setup.sh script and only attach VMD devices to uio/vfio.
49 $rootdir/scripts/setup.sh reset
50
51 vmd_id=$(grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h | awk -F"x" '{print $2}')
52
53 for bdf in $(iter_pci_dev_id 8086 $vmd_id); do
54 if pci_can_use $bdf; then
55 VMD_WHITELIST+=("$bdf")
56 fi
57 done
58 PCI_WHITELIST="${VMD_WHITELIST[*]}" $rootdir/scripts/setup.sh
59
60 pci_devs=$($SPDK_BIN_DIR/spdk_lspci | grep "NVMe disk behind VMD" | awk '{print $1}')
61
62 if [[ -z "$pci_devs" ]]; then
63 echo "Couldn't find any NVMe device behind a VMD."
64 exit 1
65 fi
66
67 run_test "vmd_identify" vmd_identify
68 run_test "vmd_hello_world" $SPDK_EXAMPLE_DIR/hello_world -V
69 run_test "vmd_perf" vmd_perf
70 if [[ $CONFIG_FIO_PLUGIN == y ]]; then
71 run_test "vmd_fio" vmd_fio
72 fi
73
74 run_test "vmd_bdev_svc" vmd_bdev_svc
75
76 # Re-run setup.sh again so that other tests may continue
77 $rootdir/scripts/setup.sh reset
78 $rootdir/scripts/setup.sh