Skip to content

Commit 233cdfb

Browse files
committed
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 <[email protected]>
2 parents 71de5b2 + e860419 commit 233cdfb

File tree

11 files changed

+112
-53
lines changed

11 files changed

+112
-53
lines changed

tools/testing/selftests/drivers/net/mlxsw/devlink_trap_control.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ ALL_TESTS="
8787
NUM_NETIFS=4
8888
source $lib_dir/lib.sh
8989
source $lib_dir/devlink_lib.sh
90+
source mlxsw_lib.sh
9091

9192
h1_create()
9293
{
@@ -626,8 +627,7 @@ ipv6_redirect_test()
626627

627628
ptp_event_test()
628629
{
629-
# PTP is only supported on Spectrum-1, for now.
630-
[[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return
630+
mlxsw_only_on_spectrum 1 || return
631631

632632
# PTP Sync (0)
633633
devlink_trap_stats_test "PTP Time-Critical Event Message" "ptp_event" \
@@ -638,8 +638,7 @@ ptp_event_test()
638638

639639
ptp_general_test()
640640
{
641-
# PTP is only supported on Spectrum-1, for now.
642-
[[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return
641+
mlxsw_only_on_spectrum 1 || return
643642

644643
# PTP Announce (b)
645644
devlink_trap_stats_test "PTP General Message" "ptp_general" \

tools/testing/selftests/drivers/net/mlxsw/devlink_trap_policer.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,17 @@ __rate_test()
272272

273273
rate_test()
274274
{
275-
local id
275+
local last_policer=$(devlink -j -p trap policer show |
276+
jq '[.[]["'$DEVLINK_DEV'"][].policer] | max')
276277

277-
for id in $(devlink_trap_policer_ids_get); do
278-
echo
279-
log_info "Running rate test for policer $id"
280-
__rate_test $id
281-
done
278+
log_info "Running rate test for policer 1"
279+
__rate_test 1
280+
281+
log_info "Running rate test for policer $((last_policer / 2))"
282+
__rate_test $((last_policer / 2))
283+
284+
log_info "Running rate test for policer $last_policer"
285+
__rate_test $last_policer
282286
}
283287

284288
__burst_test()
@@ -342,13 +346,17 @@ __burst_test()
342346

343347
burst_test()
344348
{
345-
local id
349+
local last_policer=$(devlink -j -p trap policer show |
350+
jq '[.[]["'$DEVLINK_DEV'"][].policer] | max')
351+
352+
log_info "Running burst test for policer 1"
353+
__burst_test 1
354+
355+
log_info "Running burst test for policer $((last_policer / 2))"
356+
__burst_test $((last_policer / 2))
346357

347-
for id in $(devlink_trap_policer_ids_get); do
348-
echo
349-
log_info "Running burst size test for policer $id"
350-
__burst_test $id
351-
done
358+
log_info "Running burst test for policer $last_policer"
359+
__burst_test $last_policer
352360
}
353361

354362
trap cleanup EXIT

tools/testing/selftests/drivers/net/mlxsw/mlxsw_lib.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,53 @@ if [[ ! -v MLXSW_CHIP ]]; then
1111
exit 1
1212
fi
1313
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+
}

tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ nexthop_obj_offload_test()
779779
setup_wait
780780

781781
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 \
783783
dev $swp1
784784

785785
busywait "$TIMEOUT" wait_for_offload \
@@ -791,7 +791,7 @@ nexthop_obj_offload_test()
791791
ip nexthop show id 1
792792
check_err $? "nexthop marked as offloaded after setting neigh to failed state"
793793

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 \
795795
dev $swp1
796796
busywait "$TIMEOUT" wait_for_offload \
797797
ip nexthop show id 1
@@ -828,11 +828,11 @@ nexthop_obj_group_offload_test()
828828
ip nexthop add id 1 via 192.0.2.2 dev $swp1
829829
ip nexthop add id 2 via 2001:db8:1::2 dev $swp1
830830
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 \
832832
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 \
834834
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 \
836836
dev $swp1
837837

838838
busywait "$TIMEOUT" wait_for_offload \
@@ -888,11 +888,11 @@ nexthop_obj_bucket_offload_test()
888888
ip nexthop add id 1 via 192.0.2.2 dev $swp1
889889
ip nexthop add id 2 via 2001:db8:1::2 dev $swp1
890890
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 \
892892
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 \
894894
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 \
896896
dev $swp1
897897

898898
busywait "$TIMEOUT" wait_for_offload \
@@ -921,7 +921,7 @@ nexthop_obj_bucket_offload_test()
921921
check_err $? "nexthop bucket not marked as offloaded after revalidating nexthop"
922922

923923
# 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 \
925925
dev $swp1
926926
busywait "$TIMEOUT" wait_for_offload \
927927
ip nexthop bucket show nhid 2
@@ -971,9 +971,9 @@ nexthop_obj_route_offload_test()
971971
setup_wait
972972

973973
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 \
975975
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 \
977977
dev $swp1
978978

979979
ip route replace 198.51.100.0/24 nhid 1

tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ CHECK_TC="yes"
7373
lib_dir=$(dirname $0)/../../../net/forwarding
7474
source $lib_dir/lib.sh
7575
source $lib_dir/devlink_lib.sh
76+
source mlxsw_lib.sh
7677
source qos_lib.sh
7778

7879
ipaddr()
@@ -479,10 +480,7 @@ do_ecn_test_perband()
479480
local vlan=$1; shift
480481
local limit=$1; shift
481482

482-
# Per-band ECN counters are not supported on Spectrum-1 and Spectrum-2.
483-
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ||
484-
"$DEVLINK_VIDDID" == "15b3:cf6c" ]] && return
485-
483+
mlxsw_only_on_spectrum 3+ || return
486484
__do_ecn_test get_qdisc_nmarked "$vlan" "$limit" "per-band ECN"
487485
}
488486

@@ -584,6 +582,8 @@ do_mark_test()
584582
local should_fail=$1; shift
585583
local base
586584

585+
mlxsw_only_on_spectrum 2+ || return
586+
587587
RET=0
588588

589589
start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
@@ -632,6 +632,8 @@ do_drop_test()
632632
local base
633633
local now
634634

635+
mlxsw_only_on_spectrum 2+ || return
636+
635637
RET=0
636638

637639
start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) $h3_mac

tools/testing/selftests/drivers/net/mlxsw/spectrum-2/resource_scale.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ NUM_NETIFS=6
77
source $lib_dir/lib.sh
88
source $lib_dir/tc_common.sh
99
source $lib_dir/devlink_lib.sh
10+
source ../mlxsw_lib.sh
1011

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
1613

1714
current_test=""
1815

tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_lib_spectrum.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
# SPDX-License-Identifier: GPL-2.0
33

44
source "../../../../net/forwarding/devlink_lib.sh"
5+
source ../mlxsw_lib.sh
56

6-
if [ "$DEVLINK_VIDDID" != "15b3:cb84" ]; then
7-
echo "SKIP: test is tailored for Mellanox Spectrum"
8-
exit 1
9-
fi
7+
mlxsw_only_on_spectrum 1 || exit 1
108

119
# Needed for returning to default
1210
declare -A KVD_DEFAULTS

tools/testing/selftests/drivers/net/mlxsw/tc_restrictions.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ NUM_NETIFS=2
2020
source $lib_dir/tc_common.sh
2121
source $lib_dir/lib.sh
2222
source $lib_dir/devlink_lib.sh
23+
source mlxsw_lib.sh
2324

2425
switch_create()
2526
{
@@ -169,7 +170,7 @@ matchall_sample_egress_test()
169170

170171
# It is forbidden in mlxsw driver to have matchall with sample action
171172
# bound on egress. Spectrum-1 specific restriction
172-
[[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return
173+
mlxsw_only_on_spectrum 1 || return
173174

174175
tc qdisc add dev $swp1 clsact
175176

tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ NUM_NETIFS=8
5151
CAPTURE_FILE=$(mktemp)
5252
source $lib_dir/lib.sh
5353
source $lib_dir/devlink_lib.sh
54+
source mlxsw_lib.sh
5455

5556
# Available at https://github.com/Mellanox/libpsample
5657
require_command psample
@@ -431,7 +432,7 @@ tc_sample_md_out_tc_test()
431432
RET=0
432433

433434
# Output traffic class is not supported on Spectrum-1.
434-
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return
435+
mlxsw_only_on_spectrum 2+ || return
435436

436437
tc filter add dev $rp1 ingress protocol all pref 1 handle 101 matchall \
437438
skip_sw action sample rate 5 group 1
@@ -477,7 +478,7 @@ tc_sample_md_out_tc_occ_test()
477478
RET=0
478479

479480
# Output traffic class occupancy is not supported on Spectrum-1.
480-
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return
481+
mlxsw_only_on_spectrum 2+ || return
481482

482483
tc filter add dev $rp1 ingress protocol all pref 1 handle 101 matchall \
483484
skip_sw action sample rate 1024 group 1
@@ -521,7 +522,7 @@ tc_sample_md_latency_test()
521522
RET=0
522523

523524
# Egress sampling not supported on Spectrum-1.
524-
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return
525+
mlxsw_only_on_spectrum 2+ || return
525526

526527
tc filter add dev $rp2 egress protocol all pref 1 handle 101 matchall \
527528
skip_sw action sample rate 5 group 1
@@ -550,7 +551,7 @@ tc_sample_acl_group_conflict_test()
550551
# port with different groups.
551552

552553
# Policy-based sampling is not supported on Spectrum-1.
553-
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return
554+
mlxsw_only_on_spectrum 2+ || return
554555

555556
tc filter add dev $rp1 ingress protocol ip pref 1 handle 101 flower \
556557
skip_sw action sample rate 1024 group 1
@@ -579,7 +580,7 @@ __tc_sample_acl_rate_test()
579580
RET=0
580581

581582
# Policy-based sampling is not supported on Spectrum-1.
582-
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return
583+
mlxsw_only_on_spectrum 2+ || return
583584

584585
tc filter add dev $port $bind protocol ip pref 1 handle 101 flower \
585586
skip_sw dst_ip 198.51.100.1 action sample rate 32 group 1
@@ -631,7 +632,7 @@ tc_sample_acl_max_rate_test()
631632
RET=0
632633

633634
# Policy-based sampling is not supported on Spectrum-1.
634-
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ]] && return
635+
mlxsw_only_on_spectrum 2+ || return
635636

636637
tc filter add dev $rp1 ingress protocol ip pref 1 handle 101 flower \
637638
skip_sw action sample rate $((2 ** 24 - 1)) group 1

tools/testing/selftests/net/forwarding/devlink_lib.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,6 @@ devlink_trap_group_policer_get()
563563
| jq '.[][][]["policer"]'
564564
}
565565

566-
devlink_trap_policer_ids_get()
567-
{
568-
devlink -j -p trap policer show \
569-
| jq '.[]["'$DEVLINK_DEV'"][]["policer"]'
570-
}
571-
572566
devlink_port_by_netdev()
573567
{
574568
local if_name=$1

0 commit comments

Comments
 (0)