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	source ${current_test}_scale.sh
34
35	num_netifs_var=${current_test^^}_NUM_NETIFS
36	num_netifs=${!num_netifs_var:-$NUM_NETIFS}
37
38	for should_fail in 0 1; do
39		RET=0
40		target=$(${current_test}_get_target "$should_fail")
41		${current_test}_setup_prepare
42		setup_wait $num_netifs
43		${current_test}_test "$target" "$should_fail"
44		${current_test}_cleanup
45		devlink_reload
46		if [[ "$should_fail" -eq 0 ]]; then
47			log_test "'$current_test' $target"
48		else
49			log_test "'$current_test' overflow $target"
50		fi
51	done
52done
53current_test=""
54
55exit "$RET"
56