[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1620830927-11828-15-git-send-email-dlinkin@nvidia.com>
Date: Wed, 12 May 2021 17:48:43 +0300
From: <dlinkin@...dia.com>
To: <netdev@...r.kernel.org>
CC: <davem@...emloft.net>, <kuba@...nel.org>, <jiri@...dia.com>,
<stephen@...workplumber.org>, <dsahern@...il.com>,
<vladbu@...dia.com>, <parav@...dia.com>, <huyn@...dia.com>,
Dmytro Linkin <dlinkin@...dia.com>
Subject: [PATCH RFC net-next v2 14/18] selftest: netdevsim: Add devlink rate nodes test
From: Dmytro Linkin <dlinkin@...dia.com>
Test verifies that it is possible to create, delete and set min/max tx
rate of devlink rate node on netdevsim VF.
Co-developed-by: Vlad Buslov <vladbu@...dia.com>
Signed-off-by: Vlad Buslov <vladbu@...dia.com>
Signed-off-by: Dmytro Linkin <dlinkin@...dia.com>
Reviewed-by: Jiri Pirko <jiri@...dia.com>
---
Notes:
v1->v2:
- s/func/function/ in devlink commands
.../selftests/drivers/net/netdevsim/devlink.sh | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index 05dcefc..301d920 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -516,6 +516,14 @@ rate_leafs_get()
'.[] | to_entries | .[] | select(.value.type == "leaf") | .key | select(contains("'$handle'"))'
}
+rate_nodes_get()
+{
+ local handle=$1
+
+ cmd_jq "devlink port function rate show -j" \
+ '.[] | to_entries | .[] | select(.value.type == "node") | .key | select(contains("'$handle'"))'
+}
+
rate_attr_set()
{
local handle=$1
@@ -555,6 +563,20 @@ rate_attr_tx_rate_check()
check_err $? "Unexpected $name attr value $api_value != $rate"
}
+rate_node_add()
+{
+ local handle=$1
+
+ devlink port function rate add $handle
+}
+
+rate_node_del()
+{
+ local handle=$1
+
+ devlink port function rate del $handle
+}
+
rate_test()
{
RET=0
@@ -582,6 +604,29 @@ rate_test()
rate=$(($rate+100))
done
+ local node1_name='group1'
+ local node1="$DL_HANDLE/$node1_name"
+ rate_node_add "$node1"
+ check_err $? "Failed to add node $node1"
+
+ local num_nodes=`rate_nodes_get $DL_HANDLE | wc -w`
+ [ $num_nodes == 1 ]
+ check_err $? "Expected 1 rate node in output but got $num_nodes"
+
+ local node_tx_share=10
+ rate_attr_tx_rate_check $node1 tx_share $node_tx_share \
+ $DEBUGFS_DIR/rate_nodes/${node1##*/}/tx_share
+
+ local node_tx_max=100
+ rate_attr_tx_rate_check $node1 tx_max $node_tx_max \
+ $DEBUGFS_DIR/rate_nodes/${node1##*/}/tx_max
+
+ rate_node_del "$node1"
+ check_err $? "Failed to delete node $node1"
+ local num_nodes=`rate_nodes_get $DL_HANDLE | wc -w`
+ [ $num_nodes == 0 ]
+ check_err $? "Expected 0 rate node but got $num_nodes"
+
log_test "rate test"
}
--
1.8.3.1
Powered by blists - more mailing lists