File Index
Files and directories
Sign in
FILE

rif_counter_scale.sh

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/drivers/net/mlxsw/spectrum/rif_counter_scale.sh BASH
 1# SPDX-License-Identifier: GPL-2.0
 2source ../rif_counter_scale.sh
 3
 4rif_counter_get_target()
 5{
 6	local should_fail=$1; shift
 7	local max_cnts
 8	local max_rifs
 9	local target
10
11	max_rifs=$(devlink_resource_size_get rifs)
12	max_cnts=$(devlink_resource_size_get counters rif)
13
14	# Remove already allocated RIFs.
15	((max_rifs -= $(devlink_resource_occ_get rifs)))
16
17	# 10 KVD slots per counter, ingress+egress counters per RIF
18	((max_cnts /= 20))
19
20	# Pointless to run the overflow test if we don't have enough RIFs to
21	# host all the counters.
22	if ((max_cnts > max_rifs && should_fail)); then
23		echo 0
24		return
25	fi
26
27	target=$((max_rifs < max_cnts ? max_rifs : max_cnts))
28
29	if ((! should_fail)); then
30		echo $target
31	else
32		echo $((target + 1))
33	fi
34}
~/ Read-only file preview.