1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4lib_dir=$(dirname $0)/../../../../net/forwarding
5
6NUM_NETIFS=6
7source $lib_dir/lib.sh
8source $lib_dir/tc_common.sh
9source $lib_dir/devlink_lib.sh
10
11if [[ "$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
15fi
16
17current_test=""
18
19cleanup()
20{
21	pre_cleanup
22	if [ ! -z $current_test ]; then
23		${current_test}_cleanup
24	fi
25	# Need to reload in order to avoid router abort.
26	devlink_reload
27}
28
29trap cleanup EXIT
30
31ALL_TESTS="router tc_flower mirror_gre tc_police port"
32for current_test in ${TESTS:-$ALL_TESTS}; do
33	RET_FIN=0
34	source ${current_test}_scale.sh
35
36	num_netifs_var=${current_test^^}_NUM_NETIFS
37	num_netifs=${!num_netifs_var:-$NUM_NETIFS}
38
39	for should_fail in 0 1; do
40		RET=0
41		target=$(${current_test}_get_target "$should_fail")
42		${current_test}_setup_prepare
43		setup_wait $num_netifs
44		${current_test}_test "$target" "$should_fail"
45		${current_test}_cleanup
46		devlink_reload
47		if [[ "$should_fail" -eq 0 ]]; then
48			log_test "'$current_test' $target"
49		else
50			log_test "'$current_test' overflow $target"
51		fi
52		RET_FIN=$(( RET_FIN || RET ))
53	done
54done
55current_test=""
56
57exit "$RET_FIN"
58