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