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" ]; then
12	echo "SKIP: test is tailored for Mellanox Spectrum-2"
13	exit 1
14fi
15
16current_test=""
17
18cleanup()
19{
20	pre_cleanup
21	if [ ! -z $current_test ]; then
22		${current_test}_cleanup
23	fi
24	# Need to reload in order to avoid router abort.
25	devlink_reload
26}
27
28trap cleanup EXIT
29
30ALL_TESTS="router tc_flower mirror_gre"
31for current_test in ${TESTS:-$ALL_TESTS}; do
32	source ${current_test}_scale.sh
33
34	num_netifs_var=${current_test^^}_NUM_NETIFS
35	num_netifs=${!num_netifs_var:-$NUM_NETIFS}
36
37	for should_fail in 0 1; do
38		RET=0
39		target=$(${current_test}_get_target "$should_fail")
40		${current_test}_setup_prepare
41		setup_wait $num_netifs
42		${current_test}_test "$target" "$should_fail"
43		${current_test}_cleanup
44		devlink_reload
45		if [[ "$should_fail" -eq 0 ]]; then
46			log_test "'$current_test' $target"
47		else
48			log_test "'$current_test' overflow $target"
49		fi
50	done
51done
52current_test=""
53
54exit "$RET"
55