1 # SPDX-License-Identifier: GPL-2.0
2 source ../rif_counter_scale.sh
4 rif_counter_get_target()
6 local should_fail=$1; shift
11 max_rifs=$(devlink_resource_size_get rifs)
12 max_cnts=$(devlink_resource_size_get counters rif)
14 # Remove already allocated RIFs.
15 ((max_rifs -= $(devlink_resource_occ_get rifs)))
17 # 10 KVD slots per counter, ingress+egress counters per RIF
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
27 target=$((max_rifs < max_cnts ? max_rifs : max_cnts))
29 if ((! should_fail)); then