if [[ ! -v DEVLINK_DEV ]]; then
DEVLINK_DEV=$(devlink port show "${NETIFS[p1]:-$NETIF_NO_CABLE}" -j \
| jq -r '.port | keys[]' | cut -d/ -f-2) if [ -z "$DEVLINK_DEV" ]; then echo"SKIP: ${NETIFS[p1]} has no devlink device registered for it"
exit $ksft_skip fi if [[ "$(echo $DEVLINK_DEV | grep -c pci)" -eq 0 ]]; then echo"SKIP: devlink device's bus is not PCI"
exit $ksft_skip fi
DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \
-n | cut -d" " -f3) elif [[ ! -z "$DEVLINK_DEV" ]]; then
devlink dev show $DEVLINK_DEV &> /dev/null if [ $? -ne 0 ]; then echo"SKIP: devlink device \"$DEVLINK_DEV\" not found"
exit $ksft_skip fi fi
devlink dev reload "$DEVLINK_DEV" &> /dev/null
check_err $? "Failed reload"
still_pending=$(devlink resource show "$DEVLINK_DEV" | \
grep -c "size_new")
check_err $still_pending "Failed reload - There are still unset sizes"
udevadm settle
}
declare -A DEVLINK_ORIG
# Changing pool type from static to dynamic causes reinterpretation of threshold # values. They therefore need to be saved before pool type is changed, then the # pool type can be changed, and then the new values need to be set up. Therefore # instead of saving the current state implicitly in the _set call, provide # functions for all three primitives: save, set, and restore.
devlink_port_pool_threshold()
{
local port=$1; shift
local pool=$1; shift
devlink sb port pool show $port pool $pool -j \
| jq '.port_pool."'"$port"'"[].threshold'
}
devlink_port_pool_th_save()
{
local port=$1; shift
local pool=$1; shift
local key="port_pool($port,$pool).threshold"
devlink_port_pool_th_set()
{
local port=$1; shift
local pool=$1; shift
local th=$1; shift
devlink sb port pool set $port pool $pool th $th
}
devlink_port_pool_th_restore()
{
local port=$1; shift
local pool=$1; shift
local key="port_pool($port,$pool).threshold"
local -a orig=(${DEVLINK_ORIG[$key]})
if [[ -z $orig ]]; then echo"WARNING: Mismatched devlink_port_pool_th_restore" else
devlink sb port pool set $port pool $pool th $orig fi
}
devlink_pool_size_thtype()
{
local pool=$1; shift
devlink sb pool show "$DEVLINK_DEV" pool $pool -j \
| jq -r '.pool[][] | (.size, .thtype)'
}
devlink_pool_size_thtype_save()
{
local pool=$1; shift
local key="pool($pool).size_thtype"
devlink_pool_size_thtype_set()
{
local pool=$1; shift
local thtype=$1; shift
local size=$1; shift
devlink sb pool set "$DEVLINK_DEV" pool $pool size $size thtype $thtype
}
devlink_pool_size_thtype_restore()
{
local pool=$1; shift
local key="pool($pool).size_thtype"
local -a orig=(${DEVLINK_ORIG[$key]})
if [[ -z ${orig[0]} ]]; then echo"WARNING: Mismatched devlink_pool_size_thtype_restore" else
devlink sb pool set "$DEVLINK_DEV" pool $pool \
size ${orig[0]} thtype ${orig[1]} fi
}
devlink_tc_bind_pool_th()
{
local port=$1; shift
local tc=$1; shift
local dir=$1; shift
devlink sb tc bind show $port tc $tc type $dir -j \
| jq -r '.tc_bind[][] | (.pool, .threshold)'
}
devlink_tc_bind_pool_th_save()
{
local port=$1; shift
local tc=$1; shift
local dir=$1; shift
local key="tc_bind($port,$dir,$tc).pool_th"
devlink_tc_bind_pool_th_set()
{
local port=$1; shift
local tc=$1; shift
local dir=$1; shift
local pool=$1; shift
local th=$1; shift
devlink sb tc bind set $port tc $tc type $dir pool $pool th $th
}
devlink_tc_bind_pool_th_restore()
{
local port=$1; shift
local tc=$1; shift
local dir=$1; shift
local key="tc_bind($port,$dir,$tc).pool_th"
local -a orig=(${DEVLINK_ORIG[$key]})
if [[ -z ${orig[0]} ]]; then echo"WARNING: Mismatched devlink_tc_bind_pool_th_restore" else
devlink sb tc bind set $port tc $tc type $dir \
pool ${orig[0]} th ${orig[1]} fi
}
if [[ $t0_packets -eq $t1_packets && $t0_bytes -eq $t1_bytes ]]; then
return 0 else
return 1 fi
}
devlink_trap_exception_test()
{
local trap_name=$1; shift
local group_name
group_name=$(devlink_trap_group_get $trap_name)
devlink_trap_stats_idle_test $trap_name
check_fail $? "Trap stats idle when packets should have been trapped"
devlink_trap_group_stats_idle_test $group_name
check_fail $? "Trap group idle when packets should have been trapped"
}
devlink_trap_drop_test()
{
local trap_name=$1; shift
local dev=$1; shift
local handle=$1; shift
local group_name
group_name=$(devlink_trap_group_get $trap_name)
# This is the common part of all the tests. It checks that stats are # initially idle, then non-idle after changing the trap action and # finally idle again. It also makes sure the packets are dropped and # never forwarded.
devlink_trap_stats_idle_test $trap_name
check_err $? "Trap stats not idle with initial drop action"
devlink_trap_group_stats_idle_test $group_name
check_err $? "Trap group stats not idle with initial drop action"
devlink_trap_action_set $trap_name "trap"
devlink_trap_stats_idle_test $trap_name
check_fail $? "Trap stats idle after setting action to trap"
devlink_trap_group_stats_idle_test $group_name
check_fail $? "Trap group stats idle after setting action to trap"
devlink_trap_action_set $trap_name "drop"
devlink_trap_stats_idle_test $trap_name
check_err $? "Trap stats not idle after setting action to drop"
devlink_trap_group_stats_idle_test $group_name
check_err $? "Trap group stats not idle after setting action to drop"
tc_check_packets "dev $dev egress" $handle 0
check_err $? "Packets were not dropped"
}
devlink_trap_drop_cleanup()
{
local mz_pid=$1; shift
local dev=$1; shift
local proto=$1; shift
local pref=$1; shift
local handle=$1; shift
kill_process $mz_pid
tc filter del dev $dev egress protocol $proto pref $pref handle $handle flower
}
devlink_trap_stats_check()
{
local trap_name=$1; shift
local send_one="$@"
local t0_packets
local t1_packets
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.