26 lines · bash
1# SPDX-License-Identifier: GPL-2.02source ../tc_flower_scale.sh3 4tc_flower_get_target()5{6 local should_fail=$1; shift7 local max_cnts8 9 # The driver associates a counter with each tc filter, which means the10 # number of supported filters is bounded by the number of available11 # counters.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))19 20 if ((! should_fail)); then21 echo $max_cnts22 else23 echo $((max_cnts + 1))24 fi25}26