1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2022 Intel Corporation 4# All rights reserved. 5# 6 7testdir=$(readlink -f $(dirname $0)) 8rootdir=$(readlink -f $testdir/../..) 9source $rootdir/test/common/autotest_common.sh 10 11accel_perf() { 12 "$SPDK_EXAMPLE_DIR/accel_perf" -c <(build_accel_config) "$@" 13} 14 15accel_test() { 16 local accel_opc 17 local accel_module 18 19 while IFS=":" read -r var val; do 20 val=${val##+( )} 21 case "$var" in 22 "Module") accel_module=$val ;; 23 "Workload Type") accel_opc=$val ;; 24 esac 25 done < <(accel_perf "$@") 26 27 [[ -n $accel_module && -n $accel_opc && "$accel_module" == "${expected_opcs[$accel_opc]}" ]] 28} 29 30build_accel_config() { 31 accel_json_cfg=() 32 [[ $SPDK_TEST_ACCEL_DSA -gt 0 ]] && accel_json_cfg+=('{"method": "dsa_scan_accel_module"}') 33 [[ $SPDK_TEST_ACCEL_IAA -gt 0 ]] && accel_json_cfg+=('{"method": "iaa_scan_accel_module"}') 34 [[ $SPDK_TEST_IOAT -gt 0 ]] && accel_json_cfg+=('{"method": "ioat_scan_accel_module"}') 35 36 if [[ $COMPRESSDEV ]]; then 37 accel_json_cfg+=('{"method": "compressdev_scan_accel_module", "params":{"pmd": 0}}') 38 fi 39 40 local IFS="," 41 jq -r '.' <<- JSON 42 { 43 "subsystems": [ 44 { 45 "subsystem": "accel", 46 "config": [ 47 ${accel_json_cfg[*]} 48 ] 49 } 50 ] 51 } 52 JSON 53} 54 55check_save_config() { 56 $rpc_py save_config | jq -r '.subsystems[] | select(.subsystem=="accel").config[]' | grep "$1" 57} 58 59function get_expected_opcs() { 60 trap 'killprocess $spdk_tgt_pid; exit 1' ERR 61 $SPDK_BIN_DIR/spdk_tgt -c <(build_accel_config) & 62 spdk_tgt_pid=$! 63 waitforlisten $spdk_tgt_pid 64 65 [[ $SPDK_TEST_ACCEL_DSA -gt 0 ]] && check_save_config "dsa_scan_accel_module" 66 [[ $SPDK_TEST_ACCEL_IAA -gt 0 ]] && check_save_config "iaa_scan_accel_module" 67 [[ $SPDK_TEST_IOAT -gt 0 ]] && check_save_config "ioat_scan_accel_module" 68 [[ $COMPRESSDEV ]] && check_save_config "compressdev_scan_accel_module" 69 70 exp_opcs=($($rpc_py accel_get_opc_assignments | jq -r ". | to_entries | map(\"\(.key)=\(.value)\") | .[]")) 71 for opc_opt in "${exp_opcs[@]}"; do 72 IFS="=" read -r opc module <<< $opc_opt 73 expected_opcs["$opc"]=$module 74 done 75 killprocess $spdk_tgt_pid 76 trap - ERR 77} 78 79# Run spdk_bin once and initialize accel modules based on SPDK_TEST_ACCEL_* flags. 80# Create a list of opcodes and assigned modules to be used later for post-accel_perf test runs. 81declare -A expected_opcs 82get_expected_opcs 83 84# Run some additional simple tests; mostly focused 85# around accel_perf example app itself, not necessarily 86# testing actual accel modules. 87# Cover the help message. Not really a test, but 88# it doesn't fit anywhere else. 89run_test "accel_help" accel_perf -h &> /dev/null 90# Filename required for compress operations 91run_test "accel_missing_filename" NOT accel_perf -t 1 -w compress 92# Compression does not support verify option 93run_test "accel_compress_verify" NOT accel_perf -t 1 -w compress -l $testdir/bib -y 94# Trigger error by specifying wrong workload type 95run_test "accel_wrong_workload" NOT accel_perf -t 1 -w foobar 96# Use negative number for source buffers parameters 97run_test "accel_negative_buffers" NOT accel_perf -t 1 -w xor -y -x -1 98 99#Run through all SW ops with defaults for a quick sanity check 100#To save time, only use verification case 101run_test "accel_crc32c" accel_test -t 1 -w crc32c -S 32 -y 102run_test "accel_crc32c_C2" accel_test -t 1 -w crc32c -y -C 2 103run_test "accel_copy" accel_test -t 1 -w copy -y 104run_test "accel_fill" accel_test -t 1 -w fill -f 128 -q 64 -a 64 -y 105run_test "accel_copy_crc32c" accel_test -t 1 -w copy_crc32c -y 106run_test "accel_copy_crc32c_C2" accel_test -t 1 -w copy_crc32c -y -C 2 107run_test "accel_dualcast" accel_test -t 1 -w dualcast -y 108run_test "accel_compare" accel_test -t 1 -w compare -y 109run_test "accel_xor" accel_test -t 1 -w xor -y 110run_test "accel_xor" accel_test -t 1 -w xor -y -x 3 111run_test "accel_dif_verify" accel_test -t 1 -w dif_verify 112run_test "accel_dif_generate" accel_test -t 1 -w dif_generate 113run_test "accel_dif_generate_copy" accel_test -t 1 -w dif_generate_copy 114# do not run compress/decompress unless ISAL is installed 115if [[ $CONFIG_ISAL == y ]]; then 116 run_test "accel_comp" accel_test -t 1 -w compress -l $testdir/bib 117 run_test "accel_decomp" accel_test -t 1 -w decompress -l $testdir/bib -y 118 run_test "accel_decmop_full" accel_test -t 1 -w decompress -l $testdir/bib -y -o 0 119 run_test "accel_decomp_mcore" accel_test -t 1 -w decompress -l $testdir/bib -y -m 0xf 120 run_test "accel_decomp_full_mcore" accel_test -t 1 -w decompress -l $testdir/bib -y -o 0 -m 0xf 121 run_test "accel_decomp_mthread" accel_test -t 1 -w decompress -l $testdir/bib -y -T 2 122 run_test "accel_deomp_full_mthread" accel_test -t 1 -w decompress -l $testdir/bib -y -o 0 -T 2 123fi 124if [[ $CONFIG_DPDK_COMPRESSDEV == y ]]; then 125 COMPRESSDEV=1 126 get_expected_opcs 127 run_test "accel_cdev_comp" accel_test -t 1 -w compress -l $testdir/bib 128 run_test "accel_cdev_decomp" accel_test -t 1 -w decompress -l $testdir/bib -y 129 run_test "accel_cdev_decmop_full" accel_test -t 1 -w decompress -l $testdir/bib -y -o 0 130 run_test "accel_cdev_decomp_mcore" accel_test -t 1 -w decompress -l $testdir/bib -y -m 0xf 131 run_test "accel_cdev_decomp_full_mcore" accel_test -t 1 -w decompress -l $testdir/bib -y -o 0 -m 0xf 132 run_test "accel_cdev_decomp_mthread" accel_test -t 1 -w decompress -l $testdir/bib -y -T 2 133 run_test "accel_cdev_deomp_full_mthread" accel_test -t 1 -w decompress -l $testdir/bib -y -o 0 -T 2 134 unset COMPRESSDEV 135fi 136 137run_test "accel_dif_functional_tests" "$testdir/dif/dif" -c <(build_accel_config) 138