Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: forwarding: ETS: Use Qdisc counters

Currently the SW-datapath ETS selftests use "ip link" stats to obtain the
number of packets that went through a given band. mlxsw then uses ethtool
per-priority counters.

Instead, change both to use qdiscs. In SW datapath this is the obvious
choice, and now that mlxsw offloads FIFO, this should work on the offloaded
datapath as well. This has the effect of verifying that the FIFO offload
works.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Machata and committed by
David S. Miller
b9b72999 7bec1a45

+30 -13
+11 -3
tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh
··· 56 56 } 57 57 58 58 # Callback from sch_ets_tests.sh 59 - get_stats() 59 + collect_stats() 60 60 { 61 - local band=$1; shift 61 + local -a streams=("$@") 62 + local stream 62 63 63 - ethtool_stats_get "$h2" rx_octets_prio_$band 64 + # Wait for qdisc counter update so that we don't get it mid-way through. 65 + busywait_for_counter 1000 +1 \ 66 + qdisc_parent_stats_get $swp2 10:$((${streams[0]} + 1)) .bytes \ 67 + > /dev/null 68 + 69 + for stream in ${streams[@]}; do 70 + qdisc_parent_stats_get $swp2 10:$((stream + 1)) .bytes 71 + done 64 72 } 65 73 66 74 bail_on_lldpad
+10
tools/testing/selftests/net/forwarding/lib.sh
··· 655 655 | jq '.[] | select(.handle == "'"$handle"'") | '"$selector" 656 656 } 657 657 658 + qdisc_parent_stats_get() 659 + { 660 + local dev=$1; shift 661 + local parent=$1; shift 662 + local selector=$1; shift 663 + 664 + tc -j -s qdisc show dev "$dev" invisible \ 665 + | jq '.[] | select(.parent == "'"$parent"'") | '"$selector" 666 + } 667 + 658 668 humanize() 659 669 { 660 670 local speed=$1; shift
+6 -3
tools/testing/selftests/net/forwarding/sch_ets.sh
··· 34 34 } 35 35 36 36 # Callback from sch_ets_tests.sh 37 - get_stats() 37 + collect_stats() 38 38 { 39 - local stream=$1; shift 39 + local -a streams=("$@") 40 + local stream 40 41 41 - link_stats_get $h2.1$stream rx bytes 42 + for stream in ${streams[@]}; do 43 + qdisc_parent_stats_get $swp2 10:$((stream + 1)) .bytes 44 + done 42 45 } 43 46 44 47 ets_run
+3 -7
tools/testing/selftests/net/forwarding/sch_ets_tests.sh
··· 2 2 3 3 # Global interface: 4 4 # $put -- port under test (e.g. $swp2) 5 - # get_stats($band) -- A function to collect stats for band 5 + # collect_stats($streams...) -- A function to get stats for individual streams 6 6 # ets_start_traffic($band) -- Start traffic for this band 7 7 # ets_change_qdisc($op, $dev, $nstrict, $quanta...) -- Add or change qdisc 8 8 ··· 94 94 95 95 sleep 10 96 96 97 - t0=($(for stream in ${streams[@]}; do 98 - get_stats $stream 99 - done)) 97 + t0=($(collect_stats "${streams[@]}")) 100 98 101 99 sleep 10 102 100 103 - t1=($(for stream in ${streams[@]}; do 104 - get_stats $stream 105 - done)) 101 + t1=($(collect_stats "${streams[@]}")) 106 102 d=($(for ((i = 0; i < ${#streams[@]}; i++)); do 107 103 echo $((${t1[$i]} - ${t0[$i]})) 108 104 done))