1#!/usr/bin/env bash 2 3testdir=$(readlink -f $(dirname $0)) 4rootdir=$(readlink -f $testdir/../../..) 5source $rootdir/test/common/autotest_common.sh 6source $rootdir/test/nvmf/common.sh 7 8gather_supported_nvmf_pci_devs 9TCP_INTERFACE_LIST=("${net_devs[@]}") 10if ((${#TCP_INTERFACE_LIST[@]} == 0)); then 11 echo "ERROR: Physical TCP interfaces are not ready" 12 exit 1 13fi 14 15rpc_py="$rootdir/scripts/rpc.py" 16perf="$SPDK_EXAMPLE_DIR/perf" 17 18function adq_configure_driver() { 19 # Enable adding flows to hardware 20 "${NVMF_TARGET_NS_CMD[@]}" ethtool --offload $NVMF_TARGET_INTERFACE hw-tc-offload on 21 # ADQ driver turns on this switch by default, we need to turn it off for SPDK testing 22 "${NVMF_TARGET_NS_CMD[@]}" ethtool --set-priv-flags $NVMF_TARGET_INTERFACE channel-pkt-inspect-optimize off 23 # Since sockets are non-blocking, a non-zero value of net.core.busy_read is sufficient 24 sysctl -w net.core.busy_poll=1 25 sysctl -w net.core.busy_read=1 26 27 tc=/usr/sbin/tc 28 # Create 2 traffic classes and 2 tc1 queues 29 "${NVMF_TARGET_NS_CMD[@]}" $tc qdisc add dev $NVMF_TARGET_INTERFACE root \ 30 mqprio num_tc 2 map 0 1 queues 2@0 2@2 hw 1 mode channel 31 "${NVMF_TARGET_NS_CMD[@]}" $tc qdisc add dev $NVMF_TARGET_INTERFACE ingress 32 # TC filter is configured using target address (traddr) and port number (trsvcid) to steer packets 33 "${NVMF_TARGET_NS_CMD[@]}" $tc filter add dev $NVMF_TARGET_INTERFACE protocol \ 34 ip parent ffff: prio 1 flower dst_ip $NVMF_FIRST_TARGET_IP/32 ip_proto tcp dst_port $NVMF_PORT skip_sw hw_tc 1 35 # Setup mechanism for Tx queue selection based on Rx queue(s) map 36 "${NVMF_TARGET_NS_CMD[@]}" $rootdir/scripts/perf/nvmf/set_xps_rxqs $NVMF_TARGET_INTERFACE 37} 38 39function adq_configure_nvmf_target() { 40 $rpc_py sock_impl_set_options --enable-placement-id $1 --enable-zerocopy-send-server -i posix 41 $rpc_py framework_start_init 42 $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS --io-unit-size 8192 --sock-priority $1 43 $rpc_py bdev_malloc_create 64 512 -b Malloc1 44 $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 45 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 46 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 47} 48 49function adq_reload_driver() { 50 rmmod ice 51 modprobe ice 52 sleep 5 53} 54 55# Clear the previous configuration that may have an impact. 56# At present, ADQ configuration is only applicable to the ice driver. 57adq_reload_driver 58 59# We are going to run the test twice, once with ADQ enabled and once with it disabled. 60# The nvmf target is given 4 cores and ADQ creates queues in one traffic class. We then run 61# perf with 4 cores (i.e. 4 connections) and examine how the connections are allocated to the nvmf target's 62# poll groups. 63 64# When ADQ is disabled, we expect 1 connection on each of the 4 poll groups. 65nvmftestinit 66nvmfappstart -m 0xF --wait-for-rpc 67adq_configure_nvmf_target 0 68$perf -q 64 -o 4096 -w randread -t 10 -c 0xF0 \ 69 -r "trtype:${TEST_TRANSPORT} adrfam:IPv4 traddr:${NVMF_FIRST_TARGET_IP} trsvcid:${NVMF_PORT} \ 70 subnqn:nqn.2016-06.io.spdk:cnode1" & 71perfpid=$! 72sleep 2 73 74count=$("$rpc_py" nvmf_get_stats | jq -r '.poll_groups[] | select(.current_io_qpairs == 1) | length' | wc -l) 75if [[ "$count" -ne 4 ]]; then 76 echo "ERROR: With ADQ disabled, connections were not evenly distributed amongst poll groups!" 77 exit 1 78fi 79wait $perfpid 80nvmftestfini 81 82adq_reload_driver 83 84# When ADQ is enabled, we expect the connections to reside on AT MOST two poll groups. 85nvmftestinit 86adq_configure_driver 87nvmfappstart -m 0xF --wait-for-rpc 88adq_configure_nvmf_target 1 89$perf -q 64 -o 4096 -w randread -t 10 -c 0xF0 \ 90 -r "trtype:${TEST_TRANSPORT} adrfam:IPv4 traddr:${NVMF_FIRST_TARGET_IP} trsvcid:${NVMF_PORT} \ 91 subnqn:nqn.2016-06.io.spdk:cnode1" & 92perfpid=$! 93sleep 2 94 95count=$("$rpc_py" nvmf_get_stats | jq -r '.poll_groups[] | select(.current_io_qpairs == 0) | length' | wc -l) 96if [[ "$count" -lt 2 ]]; then 97 echo "ERROR: With ADQ enabled, did not find 0 connections on 2 of the poll groups!" 98 exit 1 99fi 100 101wait $perfpid 102nvmftestfini 103 104trap - SIGINT SIGTERM EXIT 105