Commit 31f07233 authored by Dmytro Linkin's avatar Dmytro Linkin Committed by David S. Miller

selftest: netdevsim: Add devlink port shared/max tx rate test

Test verifies that netdevsim VFs can set and retrieve shared/max tx
rate through new devlink API.
Co-developed-by: default avatarVlad Buslov <vladbu@nvidia.com>
Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
Signed-off-by: default avatarDmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 605c4f8f
...@@ -516,6 +516,45 @@ rate_leafs_get() ...@@ -516,6 +516,45 @@ rate_leafs_get()
'.[] | to_entries | .[] | select(.value.type == "leaf") | .key | select(contains("'$handle'"))' '.[] | to_entries | .[] | select(.value.type == "leaf") | .key | select(contains("'$handle'"))'
} }
rate_attr_set()
{
local handle=$1
local name=$2
local value=$3
local units=$4
devlink port function rate set $handle $name $value$units
}
rate_attr_get()
{
local handle=$1
local name=$2
cmd_jq "devlink port function rate show $handle -j" '.[][].'$name
}
rate_attr_tx_rate_check()
{
local handle=$1
local name=$2
local rate=$3
local debug_file=$4
rate_attr_set $handle $name $rate mbit
check_err $? "Failed to set $name value"
local debug_value=$(cat $debug_file)
check_err $? "Failed to read $name value from debugfs"
[ "$debug_value" == "$rate" ]
check_err $? "Unexpected $name debug value $debug_value != $rate"
local api_value=$(( $(rate_attr_get $handle $name) * 8 / 1000000 ))
check_err $? "Failed to get $name attr value"
[ "$api_value" == "$rate" ]
check_err $? "Unexpected $name attr value $api_value != $rate"
}
rate_test() rate_test()
{ {
RET=0 RET=0
...@@ -527,6 +566,22 @@ rate_test() ...@@ -527,6 +566,22 @@ rate_test()
[ "$num_leafs" == "$VF_COUNT" ] [ "$num_leafs" == "$VF_COUNT" ]
check_err $? "Expected $VF_COUNT rate leafs but got $num_leafs" check_err $? "Expected $VF_COUNT rate leafs but got $num_leafs"
rate=10
for r_obj in $leafs
do
rate_attr_tx_rate_check $r_obj tx_share $rate \
$DEBUGFS_DIR/ports/${r_obj##*/}/tx_share
rate=$(($rate+10))
done
rate=100
for r_obj in $leafs
do
rate_attr_tx_rate_check $r_obj tx_max $rate \
$DEBUGFS_DIR/ports/${r_obj##*/}/tx_max
rate=$(($rate+100))
done
log_test "rate test" log_test "rate test"
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment