Skip to content

Commit ed62af4

Browse files
idoschdavem330
authored andcommitted
selftests: spectrum-2: tc_flower_scale: Dynamically set scale target
Instead of hard coding the scale target in the test, dynamically set it based on the maximum number of flow counters and their current occupancy. Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent be00853 commit ed62af4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ source ../tc_flower_scale.sh
44
tc_flower_get_target()
55
{
66
local should_fail=$1; shift
7+
local max_cnts
78

89
# The driver associates a counter with each tc filter, which means the
910
# number of supported filters is bounded by the number of available
1011
# counters.
11-
# Currently, the driver supports 30K (30,720) flow counters and six of
12-
# these are used for multicast routing.
13-
local target=30714
12+
max_cnts=$(devlink_resource_size_get counters flow)
13+
14+
# Remove already allocated counters.
15+
((max_cnts -= $(devlink_resource_occ_get counters flow)))
16+
17+
# Each rule uses two counters, for packets and bytes.
18+
((max_cnts /= 2))
1419

1520
if ((! should_fail)); then
16-
echo $target
21+
echo $max_cnts
1722
else
18-
echo $((target + 1))
23+
echo $((max_cnts + 1))
1924
fi
2025
}

0 commit comments

Comments
 (0)