1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. 4# All rights reserved. 5# 6 7testdir=$(readlink -f $(dirname $0)) 8rootdir=$(readlink -f $testdir/../../..) 9source $rootdir/test/common/autotest_common.sh 10source $rootdir/test/nvmf/common.sh 11 12allowed_devices=${1:-"mlx5_0"} 13 14function gen_accel_mlx5_crypto_json() { 15 crypto_split_blocks=${1:-0} 16 accel_qp_size=${2:-256} 17 accel_num_requests=${3:-2047} 18 accel_driver=${4:-false} 19 20 jq . <<- JSON 21 { 22 "subsystems": [ 23 { 24 "subsystem": "accel", 25 "config": [ 26 { 27 "method": "mlx5_scan_accel_module", 28 "params": { 29 "allowed_devs": "${allowed_devices}", 30 "qp_size": ${accel_qp_size}, 31 "num_requests": ${accel_num_requests}, 32 "crypto_split_blocks": ${crypto_split_blocks}, 33 "enable_driver": ${accel_driver} 34 } 35 }, 36 { 37 "method": "accel_crypto_key_create", 38 "params": { 39 "name": "test_dek", 40 "cipher": "AES_XTS", 41 "key": "00112233445566778899001122334455", 42 "key2": "11223344556677889900112233445500" 43 } 44 } 45 ] 46 }, 47 { 48 "subsystem": "bdev", 49 "config": [ 50 { 51 "method": "bdev_malloc_create", 52 "params": { 53 "name": "Malloc0", 54 "num_blocks": 131072, 55 "block_size": 512, 56 "uuid": "e1c24cb1-dd44-4be6-8d67-de92a332013f" 57 } 58 }, 59 { 60 "method": "bdev_crypto_create", 61 "params": { 62 "base_bdev_name": "Malloc0", 63 "name": "Crypto0", 64 "key_name": "test_dek" 65 } 66 }, 67 { 68 "method": "bdev_wait_for_examine" 69 } 70 ] 71 } 72 ] 73 } 74 JSON 75} 76 77# Test crypto_split_blocks 78"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 16384 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json 8) -b "Crypto0" -f -x translate 79 80# Test fragmented crypto operation 81"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 4096 -O 17 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json) -b "Crypto0" -f -x translate 82"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 4096 -O 33 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json) -b "Crypto0" -f -x translate 83"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 131072 -O 49 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json) -b "Crypto0" -f -x translate 84"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 131072 -O 49 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json 5) -b "Crypto0" -f -x translate 85 86# Test fragmented crypto operation with platform driver enabled 87"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 131072 -O 49 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json 0 256 2047 true) -b "Crypto0" -f -x translate 88 89# Test lack of resources 90"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 131072 -O 49 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json 0 16 2047) -b "Crypto0" -f -x translate 91"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 131072 -O 49 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json 0 256 32) -b "Crypto0" -f -x translate 92"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 131072 -O 49 -w verify -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json 0 16 32) -b "Crypto0" -f -x translate 93 94# Test different modes, qdepth and IO size values 95for mode in randread randwrite randrw; do 96 for qdepth in 64 256; do 97 for io_size in 512 4096 65536 131072; do 98 echo "test: mode $mode, qdepth $qdepth, io_size $io_size" 99 "$rootdir/test/dma/test_dma/test_dma" -q $qdepth -o $io_size -w $mode -M 50 -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json) -b "Crypto0" -f -x translate 100 done 101 done 102done 103 104# Test qp recovery 105"$rootdir/test/dma/test_dma/test_dma" -q 64 -o 4096 -w randrw -M 50 -t 5 -m 0xc --json <(gen_accel_mlx5_crypto_json 8) -b "Crypto0" -f -x translate -Y 1000000 106 107trap - SIGINT SIGTERM EXIT 108