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

Merge branch 'mlxsw-selftests-updates'

Ido Schimmel says:

====================
selftests: mlxsw: Various updates

This patchset contains various updates to mlxsw selftests.

Patch #1 replaces open-coded compatibility checks with dedicated
helpers. These helpers are used to skip tests when run on incompatible
machines.

Patch #2 avoids spurious failures in some tests by using permanent
neighbours instead of reachable ones.

Patch #3 reduces the run time of a test by not iterating over all the
available trap policers.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+112 -53
+50
tools/testing/selftests/drivers/net/mlxsw/mlxsw_lib.sh
··· 11 11 exit 1 12 12 fi 13 13 fi 14 + 15 + MLXSW_SPECTRUM_REV=$(case $MLXSW_CHIP in 16 + mlxsw_spectrum) 17 + echo 1 ;; 18 + mlxsw_spectrum*) 19 + echo ${MLXSW_CHIP#mlxsw_spectrum} ;; 20 + *) 21 + echo "Couldn't determine Spectrum chip revision." \ 22 + > /dev/stderr ;; 23 + esac) 24 + 25 + mlxsw_on_spectrum() 26 + { 27 + local rev=$1; shift 28 + local op="==" 29 + local rev2=${rev%+} 30 + 31 + if [[ $rev2 != $rev ]]; then 32 + op=">=" 33 + fi 34 + 35 + ((MLXSW_SPECTRUM_REV $op rev2)) 36 + } 37 + 38 + __mlxsw_only_on_spectrum() 39 + { 40 + local rev=$1; shift 41 + local caller=$1; shift 42 + local src=$1; shift 43 + 44 + if ! mlxsw_on_spectrum "$rev"; then 45 + log_test_skip $src:$caller "(Spectrum-$rev only)" 46 + return 1 47 + fi 48 + } 49 + 50 + mlxsw_only_on_spectrum() 51 + { 52 + local caller=${FUNCNAME[1]} 53 + local src=${BASH_SOURCE[1]} 54 + local rev 55 + 56 + for rev in "$@"; do 57 + if __mlxsw_only_on_spectrum "$rev" "$caller" "$src"; then 58 + return 0 59 + fi 60 + done 61 + 62 + return 1 63 + }
+11 -11
tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh
··· 779 779 setup_wait 780 780 781 781 ip nexthop add id 1 via 192.0.2.2 dev $swp1 782 - ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud reachable \ 782 + ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud perm \ 783 783 dev $swp1 784 784 785 785 busywait "$TIMEOUT" wait_for_offload \ ··· 791 791 ip nexthop show id 1 792 792 check_err $? "nexthop marked as offloaded after setting neigh to failed state" 793 793 794 - ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud reachable \ 794 + ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud perm \ 795 795 dev $swp1 796 796 busywait "$TIMEOUT" wait_for_offload \ 797 797 ip nexthop show id 1 ··· 828 828 ip nexthop add id 1 via 192.0.2.2 dev $swp1 829 829 ip nexthop add id 2 via 2001:db8:1::2 dev $swp1 830 830 ip nexthop add id 10 group 1/2 831 - ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud reachable \ 831 + ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud perm \ 832 832 dev $swp1 833 - ip neigh replace 192.0.2.3 lladdr 00:11:22:33:44:55 nud reachable \ 833 + ip neigh replace 192.0.2.3 lladdr 00:11:22:33:44:55 nud perm \ 834 834 dev $swp1 835 - ip neigh replace 2001:db8:1::2 lladdr 00:11:22:33:44:55 nud reachable \ 835 + ip neigh replace 2001:db8:1::2 lladdr 00:11:22:33:44:55 nud perm \ 836 836 dev $swp1 837 837 838 838 busywait "$TIMEOUT" wait_for_offload \ ··· 888 888 ip nexthop add id 1 via 192.0.2.2 dev $swp1 889 889 ip nexthop add id 2 via 2001:db8:1::2 dev $swp1 890 890 ip nexthop add id 10 group 1/2 type resilient buckets 32 idle_timer 0 891 - ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud reachable \ 891 + ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud perm \ 892 892 dev $swp1 893 - ip neigh replace 192.0.2.3 lladdr 00:11:22:33:44:55 nud reachable \ 893 + ip neigh replace 192.0.2.3 lladdr 00:11:22:33:44:55 nud perm \ 894 894 dev $swp1 895 - ip neigh replace 2001:db8:1::2 lladdr 00:11:22:33:44:55 nud reachable \ 895 + ip neigh replace 2001:db8:1::2 lladdr 00:11:22:33:44:55 nud perm \ 896 896 dev $swp1 897 897 898 898 busywait "$TIMEOUT" wait_for_offload \ ··· 921 921 check_err $? "nexthop bucket not marked as offloaded after revalidating nexthop" 922 922 923 923 # Revalidate nexthop id 2 by changing its neighbour 924 - ip neigh replace 2001:db8:1::2 lladdr 00:11:22:33:44:55 nud reachable \ 924 + ip neigh replace 2001:db8:1::2 lladdr 00:11:22:33:44:55 nud perm \ 925 925 dev $swp1 926 926 busywait "$TIMEOUT" wait_for_offload \ 927 927 ip nexthop bucket show nhid 2 ··· 971 971 setup_wait 972 972 973 973 ip nexthop add id 1 via 192.0.2.2 dev $swp1 974 - ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud reachable \ 974 + ip neigh replace 192.0.2.2 lladdr 00:11:22:33:44:55 nud perm \ 975 975 dev $swp1 976 - ip neigh replace 192.0.2.3 lladdr 00:11:22:33:44:55 nud reachable \ 976 + ip neigh replace 192.0.2.3 lladdr 00:11:22:33:44:55 nud perm \ 977 977 dev $swp1 978 978 979 979 ip route replace 198.51.100.0/24 nhid 1
+6 -4
tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh
··· 73 73 lib_dir=$(dirname $0)/../../../net/forwarding 74 74 source $lib_dir/lib.sh 75 75 source $lib_dir/devlink_lib.sh 76 + source mlxsw_lib.sh 76 77 source qos_lib.sh 77 78 78 79 ipaddr() ··· 480 479 local vlan=$1; shift 481 480 local limit=$1; shift 482 481 483 - # Per-band ECN counters are not supported on Spectrum-1 and Spectrum-2. 484 - [[ "$DEVLINK_VIDDID" == "15b3:cb84" || 485 - "$DEVLINK_VIDDID" == "15b3:cf6c" ]] && return 486 - 482 + mlxsw_only_on_spectrum 3+ || return 487 483 __do_ecn_test get_qdisc_nmarked "$vlan" "$limit" "per-band ECN" 488 484 } 489 485 ··· 582 584 local should_fail=$1; shift 583 585 local base 584 586 587 + mlxsw_only_on_spectrum 2+ || return 588 + 585 589 RET=0 586 590 587 591 start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ ··· 631 631 local fetch_counter=$1; shift 632 632 local base 633 633 local now 634 + 635 + mlxsw_only_on_spectrum 2+ || return 634 636 635 637 RET=0 636 638
+2 -5
tools/testing/selftests/drivers/net/mlxsw/spectrum-2/resource_scale.sh
··· 7 7 source $lib_dir/lib.sh 8 8 source $lib_dir/tc_common.sh 9 9 source $lib_dir/devlink_lib.sh 10 + source ../mlxsw_lib.sh 10 11 11 - if [[ "$DEVLINK_VIDDID" != "15b3:cf6c" && \ 12 - "$DEVLINK_VIDDID" != "15b3:cf70" ]]; then 13 - echo "SKIP: test is tailored for Mellanox Spectrum-2 and Spectrum-3" 14 - exit 1 15 - fi 12 + mlxsw_only_on_spectrum 2+ || exit 1 16 13 17 14 current_test="" 18 15
+2 -1
tools/testing/selftests/drivers/net/mlxsw/tc_restrictions.sh
··· 20 20 source $lib_dir/tc_common.sh 21 21 source $lib_dir/lib.sh 22 22 source $lib_dir/devlink_lib.sh 23 + source mlxsw_lib.sh 23 24 24 25 switch_create() 25 26 { ··· 170 169 171 170 # It is forbidden in mlxsw driver to have matchall with sample action 172 171 # bound on egress. Spectrum-1 specific restriction 173 - [[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return 172 + mlxsw_only_on_spectrum 1 || return 174 173 175 174 tc qdisc add dev $swp1 clsact 176 175
+7 -6
tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh
··· 51 51 CAPTURE_FILE=$(mktemp) 52 52 source $lib_dir/lib.sh 53 53 source $lib_dir/devlink_lib.sh 54 + source mlxsw_lib.sh 54 55 55 56 # Available at https://github.com/Mellanox/libpsample 56 57 require_command psample ··· 432 431 RET=0 433 432 434 433 # Output traffic class is not supported on Spectrum-1. 435 - [[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return 434 + mlxsw_only_on_spectrum 2+ || return 436 435 437 436 tc filter add dev $rp1 ingress protocol all pref 1 handle 101 matchall \ 438 437 skip_sw action sample rate 5 group 1 ··· 478 477 RET=0 479 478 480 479 # Output traffic class occupancy is not supported on Spectrum-1. 481 - [[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return 480 + mlxsw_only_on_spectrum 2+ || return 482 481 483 482 tc filter add dev $rp1 ingress protocol all pref 1 handle 101 matchall \ 484 483 skip_sw action sample rate 1024 group 1 ··· 522 521 RET=0 523 522 524 523 # Egress sampling not supported on Spectrum-1. 525 - [[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return 524 + mlxsw_only_on_spectrum 2+ || return 526 525 527 526 tc filter add dev $rp2 egress protocol all pref 1 handle 101 matchall \ 528 527 skip_sw action sample rate 5 group 1 ··· 551 550 # port with different groups. 552 551 553 552 # Policy-based sampling is not supported on Spectrum-1. 554 - [[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return 553 + mlxsw_only_on_spectrum 2+ || return 555 554 556 555 tc filter add dev $rp1 ingress protocol ip pref 1 handle 101 flower \ 557 556 skip_sw action sample rate 1024 group 1 ··· 580 579 RET=0 581 580 582 581 # Policy-based sampling is not supported on Spectrum-1. 583 - [[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return 582 + mlxsw_only_on_spectrum 2+ || return 584 583 585 584 tc filter add dev $port $bind protocol ip pref 1 handle 101 flower \ 586 585 skip_sw dst_ip 198.51.100.1 action sample rate 32 group 1 ··· 632 631 RET=0 633 632 634 633 # Policy-based sampling is not supported on Spectrum-1. 635 - [[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return 634 + mlxsw_only_on_spectrum 2+ || return 636 635 637 636 tc filter add dev $rp1 ingress protocol ip pref 1 handle 101 flower \ 638 637 skip_sw action sample rate $((2 ** 24 - 1)) group 1
+9
tools/testing/selftests/net/forwarding/lib.sh
··· 286 286 return 0 287 287 } 288 288 289 + log_test_skip() 290 + { 291 + local test_name=$1 292 + local opt_str=$2 293 + 294 + printf "TEST: %-60s [SKIP]\n" "$test_name $opt_str" 295 + return 0 296 + } 297 + 289 298 log_info() 290 299 { 291 300 local msg=$1