brintos

brintos / linux-shallow public Read only

0
0
Text · 736 B · d445362 Raw
35 lines · bash
1# SPDX-License-Identifier: GPL-2.02source ../rif_counter_scale.sh3 4rif_counter_get_target()5{6	local should_fail=$1; shift7	local max_cnts8	local max_rifs9	local target10 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 RIF18	((max_cnts /= 20))19 20	# Pointless to run the overflow test if we don't have enough RIFs to21	# host all the counters.22	if ((max_cnts > max_rifs && should_fail)); then23		echo 024		return25	fi26 27	target=$((max_rifs < max_cnts ? max_rifs : max_cnts))28 29	if ((! should_fail)); then30		echo $target31	else32		echo $((target + 1))33	fi34}35