OSDN Git Service

selftests: forwarding: ETS: Use Qdisc counters
authorPetr Machata <petrm@mellanox.com>
Thu, 5 Mar 2020 07:16:44 +0000 (09:16 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Mar 2020 22:03:32 +0000 (14:03 -0800)
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>
tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh
tools/testing/selftests/net/forwarding/lib.sh
tools/testing/selftests/net/forwarding/sch_ets.sh
tools/testing/selftests/net/forwarding/sch_ets_tests.sh

index c9fc4d4..94c3712 100755 (executable)
@@ -56,11 +56,19 @@ switch_destroy()
 }
 
 # Callback from sch_ets_tests.sh
-get_stats()
+collect_stats()
 {
-       local band=$1; shift
+       local -a streams=("$@")
+       local stream
 
-       ethtool_stats_get "$h2" rx_octets_prio_$band
+       # Wait for qdisc counter update so that we don't get it mid-way through.
+       busywait_for_counter 1000 +1 \
+               qdisc_parent_stats_get $swp2 10:$((${streams[0]} + 1)) .bytes \
+               > /dev/null
+
+       for stream in ${streams[@]}; do
+               qdisc_parent_stats_get $swp2 10:$((stream + 1)) .bytes
+       done
 }
 
 bail_on_lldpad
index 7ecce65..a4a7879 100644 (file)
@@ -655,6 +655,16 @@ qdisc_stats_get()
            | jq '.[] | select(.handle == "'"$handle"'") | '"$selector"
 }
 
+qdisc_parent_stats_get()
+{
+       local dev=$1; shift
+       local parent=$1; shift
+       local selector=$1; shift
+
+       tc -j -s qdisc show dev "$dev" invisible \
+           | jq '.[] | select(.parent == "'"$parent"'") | '"$selector"
+}
+
 humanize()
 {
        local speed=$1; shift
index 40e0ad1..e60c8b4 100755 (executable)
@@ -34,11 +34,14 @@ switch_destroy()
 }
 
 # Callback from sch_ets_tests.sh
-get_stats()
+collect_stats()
 {
-       local stream=$1; shift
+       local -a streams=("$@")
+       local stream
 
-       link_stats_get $h2.1$stream rx bytes
+       for stream in ${streams[@]}; do
+               qdisc_parent_stats_get $swp2 10:$((stream + 1)) .bytes
+       done
 }
 
 ets_run
index 3c3b204..cdf689e 100644 (file)
@@ -2,7 +2,7 @@
 
 # Global interface:
 #  $put -- port under test (e.g. $swp2)
-#  get_stats($band) -- A function to collect stats for band
+#  collect_stats($streams...) -- A function to get stats for individual streams
 #  ets_start_traffic($band) -- Start traffic for this band
 #  ets_change_qdisc($op, $dev, $nstrict, $quanta...) -- Add or change qdisc
 
@@ -94,15 +94,11 @@ __ets_dwrr_test()
 
        sleep 10
 
-       t0=($(for stream in ${streams[@]}; do
-                 get_stats $stream
-             done))
+       t0=($(collect_stats "${streams[@]}"))
 
        sleep 10
 
-       t1=($(for stream in ${streams[@]}; do
-                 get_stats $stream
-             done))
+       t1=($(collect_stats "${streams[@]}"))
        d=($(for ((i = 0; i < ${#streams[@]}; i++)); do
                 echo $((${t1[$i]} - ${t0[$i]}))
             done))