151b018daSKonrad Sztyber#!/usr/bin/env bash 2eb53c232Spaul luse# SPDX-License-Identifier: BSD-3-Clause 3eb53c232Spaul luse# Copyright (C) 2021 Intel Corporation 4eb53c232Spaul luse# All rights reserved. 5eb53c232Spaul luse# 651b018daSKonrad Sztybertestdir=$(readlink -f $(dirname $0)) 751b018daSKonrad Sztyberrootdir=$(readlink -f $testdir/../../..) 851b018daSKonrad Sztyberrpc_py=$rootdir/scripts/rpc.py 951b018daSKonrad Sztyber 1051b018daSKonrad Sztybersource $rootdir/test/common/autotest_common.sh 1151b018daSKonrad Sztybersource $rootdir/test/nvmf/common.sh 1251b018daSKonrad Sztyber 1351b018daSKonrad Sztybernull_bdev_size=1024 1451b018daSKonrad Sztybernull_block_size=512 1551b018daSKonrad Sztybernull_bdev=null0 1651b018daSKonrad Sztybernvme_bdev=nvme0 1751b018daSKonrad Sztyber 1879415753SKonrad Sztyber# Since we're connecting the same bdev, we need to use a different NGUID to avoid errors when 1979415753SKonrad Sztyber# registering the bdev during bdev_nvme_attach_controller 2079415753SKonrad Sztybernguid=$(uuidgen | tr -d '-') 2179415753SKonrad Sztyber 2251b018daSKonrad Sztybernvmftestinit 2351b018daSKonrad Sztybernvmfappstart -m 0x1 2451b018daSKonrad Sztyber 2551b018daSKonrad Sztyber# First create a null bdev and expose it over NVMeoF 2651b018daSKonrad Sztyber$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS 2751b018daSKonrad Sztyber$rpc_py bdev_null_create $null_bdev $null_bdev_size $null_block_size 2851b018daSKonrad Sztyber$rpc_py bdev_wait_for_examine 2951b018daSKonrad Sztyber$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode0 -a 3079415753SKonrad Sztyber$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode0 $null_bdev -g $nguid 3151b018daSKonrad Sztyber$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode0 -t $TEST_TRANSPORT \ 3251b018daSKonrad Sztyber -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 3351b018daSKonrad Sztyber 3451b018daSKonrad Sztyber# Then attach NVMe bdev by connecting back to itself, with the target app running on a single core. 3551b018daSKonrad Sztyber# This verifies that the initialization is completely asynchronous, as each blocking call would 3651b018daSKonrad Sztyber# stall the application. 3751b018daSKonrad Sztyber$rpc_py bdev_nvme_attach_controller -b $nvme_bdev -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \ 3851b018daSKonrad Sztyber -f ipv4 -s $NVMF_PORT -n nqn.2016-06.io.spdk:cnode0 3951b018daSKonrad Sztyber 4000d58714SKonrad Sztyber# Make sure the bdev was created successfully 4100d58714SKonrad Sztyber$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 4200d58714SKonrad Sztyber 4351b018daSKonrad Sztyber# Make sure the reset is also asynchronous 4451b018daSKonrad Sztyber$rpc_py bdev_nvme_reset_controller $nvme_bdev 4551b018daSKonrad Sztyber 4600d58714SKonrad Sztyber# And that the bdev is still available after a reset 4700d58714SKonrad Sztyber$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 4800d58714SKonrad Sztyber 49c5ebb7ffSKonrad Sztyber# Finally, detach the controller to verify the detach path 50c5ebb7ffSKonrad Sztyber$rpc_py bdev_nvme_detach_controller $nvme_bdev 5151b018daSKonrad Sztyber 52f846377cSBoris Glimcher# Add new listener with TLS using PSK 53f846377cSBoris Glimcherkey_path=$(mktemp) 54f846377cSBoris Glimcherecho -n "NVMeTLSkey-1:01:MDAxMTIyMzM0NDU1NjY3Nzg4OTlhYWJiY2NkZGVlZmZwJEiQ:" > $key_path 55f846377cSBoris Glimcherchmod 0600 $key_path 5611cc2256SKonrad Sztyber$rpc_py keyring_file_add_key key0 "$key_path" 57f846377cSBoris Glimcher$rpc_py nvmf_subsystem_allow_any_host nqn.2016-06.io.spdk:cnode0 --disable 58f846377cSBoris Glimcher$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode0 -t $TEST_TRANSPORT \ 59f846377cSBoris Glimcher -a $NVMF_FIRST_TARGET_IP -s $NVMF_SECOND_PORT --secure-channel 60f846377cSBoris Glimcher$rpc_py nvmf_subsystem_add_host nqn.2016-06.io.spdk:cnode0 nqn.2016-06.io.spdk:host1 \ 6111cc2256SKonrad Sztyber --psk key0 62f846377cSBoris Glimcher 63f846377cSBoris Glimcher# Then attach NVMe bdev by connecting back to itself, with the target app running on a single core. 64f846377cSBoris Glimcher# This verifies that the initialization is completely asynchronous, as each blocking call would 65f846377cSBoris Glimcher# stall the application. 66f846377cSBoris Glimcher$rpc_py bdev_nvme_attach_controller -b $nvme_bdev -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \ 67*d341bee7SKonrad Sztyber -f ipv4 -s $NVMF_SECOND_PORT -n nqn.2016-06.io.spdk:cnode0 -q nqn.2016-06.io.spdk:host1 --psk key0 68f846377cSBoris Glimcher 69f846377cSBoris Glimcher# Make sure the bdev was created successfully 70f846377cSBoris Glimcher$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 71f846377cSBoris Glimcher 72f846377cSBoris Glimcher# Finally, detach the controller to verify the detach path 73f846377cSBoris Glimcher$rpc_py bdev_nvme_detach_controller $nvme_bdev 74f846377cSBoris Glimcher 75f846377cSBoris Glimcher# cleanup 76f846377cSBoris Glimcherrm -f $key_path 77f846377cSBoris Glimcher 7851b018daSKonrad Sztybertrap - SIGINT SIGTERM EXIT 7951b018daSKonrad Sztybernvmftestfini 80