selftests: forwarding: devlink_lib: Split devlink_..._set() into save & set
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. For that reason, set cannot subsume save, because it would be saving the wrong thing, with possibly a nonsensical value, and restore would then fail to restore the nonsensical value. Thus extract a _save() from each of the relevant _set()'s. This way it is possible to save everything up front, then to tweak it, and then restore in the required order. Signed-off-by: Petr Machata <petrm@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
611ba7536e
commit
6e0972e0c5
@ -147,17 +147,26 @@ switch_create()
|
||||
|
||||
# Make sure that ingress quotas are smaller than egress so that there is
|
||||
# room for both streams of traffic to be admitted to shared buffer.
|
||||
devlink_pool_size_thtype_save 0
|
||||
devlink_pool_size_thtype_set 0 dynamic 10000000
|
||||
devlink_pool_size_thtype_save 4
|
||||
devlink_pool_size_thtype_set 4 dynamic 10000000
|
||||
|
||||
devlink_port_pool_th_save $swp1 0
|
||||
devlink_port_pool_th_set $swp1 0 6
|
||||
devlink_tc_bind_pool_th_save $swp1 1 ingress
|
||||
devlink_tc_bind_pool_th_set $swp1 1 ingress 0 6
|
||||
|
||||
devlink_port_pool_th_save $swp2 0
|
||||
devlink_port_pool_th_set $swp2 0 6
|
||||
devlink_tc_bind_pool_th_save $swp2 2 ingress
|
||||
devlink_tc_bind_pool_th_set $swp2 2 ingress 0 6
|
||||
|
||||
devlink_tc_bind_pool_th_save $swp3 1 egress
|
||||
devlink_tc_bind_pool_th_set $swp3 1 egress 4 7
|
||||
devlink_tc_bind_pool_th_save $swp3 2 egress
|
||||
devlink_tc_bind_pool_th_set $swp3 2 egress 4 7
|
||||
devlink_port_pool_th_save $swp3 4
|
||||
devlink_port_pool_th_set $swp3 4 7
|
||||
}
|
||||
|
||||
|
@ -145,12 +145,17 @@ switch_create()
|
||||
|
||||
# Make sure that ingress quotas are smaller than egress so that there is
|
||||
# room for both streams of traffic to be admitted to shared buffer.
|
||||
devlink_port_pool_th_save $swp1 0
|
||||
devlink_port_pool_th_set $swp1 0 5
|
||||
devlink_tc_bind_pool_th_save $swp1 0 ingress
|
||||
devlink_tc_bind_pool_th_set $swp1 0 ingress 0 5
|
||||
|
||||
devlink_port_pool_th_save $swp2 0
|
||||
devlink_port_pool_th_set $swp2 0 5
|
||||
devlink_tc_bind_pool_th_save $swp2 1 ingress
|
||||
devlink_tc_bind_pool_th_set $swp2 1 ingress 0 5
|
||||
|
||||
devlink_port_pool_th_save $swp3 4
|
||||
devlink_port_pool_th_set $swp3 4 12
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,17 @@ switch_create()
|
||||
# amount of traffic that is admitted to the shared buffers. This makes
|
||||
# sure that there is always enough traffic of all types to select from
|
||||
# for the DWRR process.
|
||||
devlink_port_pool_th_save $swp1 0
|
||||
devlink_port_pool_th_set $swp1 0 12
|
||||
devlink_tc_bind_pool_th_save $swp1 0 ingress
|
||||
devlink_tc_bind_pool_th_set $swp1 0 ingress 0 12
|
||||
devlink_port_pool_th_save $swp2 4
|
||||
devlink_port_pool_th_set $swp2 4 12
|
||||
devlink_tc_bind_pool_th_save $swp2 7 egress
|
||||
devlink_tc_bind_pool_th_set $swp2 7 egress 4 5
|
||||
devlink_tc_bind_pool_th_save $swp2 6 egress
|
||||
devlink_tc_bind_pool_th_set $swp2 6 egress 4 5
|
||||
devlink_tc_bind_pool_th_save $swp2 5 egress
|
||||
devlink_tc_bind_pool_th_set $swp2 5 egress 4 5
|
||||
|
||||
# Note: sch_ets_core.sh uses VLAN ingress-qos-map to assign packet
|
||||
|
@ -208,6 +208,7 @@ switch_create()
|
||||
ip link set dev br2_11 up
|
||||
|
||||
local size=$(devlink_pool_size_thtype 0 | cut -d' ' -f 1)
|
||||
devlink_port_pool_th_save $swp3 8
|
||||
devlink_port_pool_th_set $swp3 8 $size
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,12 @@ devlink_reload()
|
||||
|
||||
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
|
||||
@ -126,14 +132,21 @@ devlink_port_pool_threshold()
|
||||
| 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_ORIG[$key]=$(devlink_port_pool_threshold $port $pool)
|
||||
}
|
||||
|
||||
devlink_port_pool_th_set()
|
||||
{
|
||||
local port=$1; shift
|
||||
local pool=$1; shift
|
||||
local th=$1; shift
|
||||
local key="port_pool($port,$pool).threshold"
|
||||
|
||||
DEVLINK_ORIG[$key]=$(devlink_port_pool_threshold $port $pool)
|
||||
devlink sb port pool set $port pool $pool th $th
|
||||
}
|
||||
|
||||
@ -142,8 +155,13 @@ 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]})
|
||||
|
||||
devlink sb port pool set $port pool $pool th ${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()
|
||||
@ -154,14 +172,20 @@ devlink_pool_size_thtype()
|
||||
| jq -r '.pool[][] | (.size, .thtype)'
|
||||
}
|
||||
|
||||
devlink_pool_size_thtype_save()
|
||||
{
|
||||
local pool=$1; shift
|
||||
local key="pool($pool).size_thtype"
|
||||
|
||||
DEVLINK_ORIG[$key]=$(devlink_pool_size_thtype $pool)
|
||||
}
|
||||
|
||||
devlink_pool_size_thtype_set()
|
||||
{
|
||||
local pool=$1; shift
|
||||
local thtype=$1; shift
|
||||
local size=$1; shift
|
||||
local key="pool($pool).size_thtype"
|
||||
|
||||
DEVLINK_ORIG[$key]=$(devlink_pool_size_thtype $pool)
|
||||
devlink sb pool set "$DEVLINK_DEV" pool $pool size $size thtype $thtype
|
||||
}
|
||||
|
||||
@ -171,8 +195,12 @@ devlink_pool_size_thtype_restore()
|
||||
local key="pool($pool).size_thtype"
|
||||
local -a orig=(${DEVLINK_ORIG[$key]})
|
||||
|
||||
devlink sb pool set "$DEVLINK_DEV" pool $pool \
|
||||
size ${orig[0]} thtype ${orig[1]}
|
||||
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()
|
||||
@ -185,6 +213,16 @@ devlink_tc_bind_pool_th()
|
||||
| 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_ORIG[$key]=$(devlink_tc_bind_pool_th $port $tc $dir)
|
||||
}
|
||||
|
||||
devlink_tc_bind_pool_th_set()
|
||||
{
|
||||
local port=$1; shift
|
||||
@ -192,9 +230,7 @@ devlink_tc_bind_pool_th_set()
|
||||
local dir=$1; shift
|
||||
local pool=$1; shift
|
||||
local th=$1; shift
|
||||
local key="tc_bind($port,$dir,$tc).pool_th"
|
||||
|
||||
DEVLINK_ORIG[$key]=$(devlink_tc_bind_pool_th $port $tc $dir)
|
||||
devlink sb tc bind set $port tc $tc type $dir pool $pool th $th
|
||||
}
|
||||
|
||||
@ -206,8 +242,12 @@ devlink_tc_bind_pool_th_restore()
|
||||
local key="tc_bind($port,$dir,$tc).pool_th"
|
||||
local -a orig=(${DEVLINK_ORIG[$key]})
|
||||
|
||||
devlink sb tc bind set $port tc $tc type $dir \
|
||||
pool ${orig[0]} th ${orig[1]}
|
||||
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
|
||||
}
|
||||
|
||||
devlink_traps_num_get()
|
||||
|
Loading…
Reference in New Issue
Block a user