[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1571766190-23943-9-git-send-email-yuvalav@mellanox.com>
Date: Tue, 22 Oct 2019 20:43:09 +0300
From: Yuval Avnery <yuvalav@...lanox.com>
To: netdev@...r.kernel.org
Cc: jiri@...lanox.com, saeedm@...lanox.com, leon@...nel.org,
davem@...emloft.net, jakub.kicinski@...ronome.com,
shuah@...nel.org, Yuval Avnery <yuvalav@...lanox.com>
Subject: [PATCH net-next 8/9] netdevsim: Add devlink vdev sefltest for netdevsim
Test will assign hw_addr to all registered vdevs and query it.
Signed-off-by: Yuval Avnery <yuvalav@...lanox.com>
Acked-by: Jiri Pirko <jiri@...lanox.com>
---
.../drivers/net/netdevsim/devlink.sh | 55 ++++++++++++++++++-
1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index ee89cd2f5bee..88ddf65b7897 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -5,12 +5,13 @@ lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="fw_flash_test params_test regions_test reload_test \
netns_reload_test resource_test dev_info_test \
- empty_reporter_test dummy_reporter_test"
+ empty_reporter_test dummy_reporter_test vdev_test"
NUM_NETIFS=0
source $lib_dir/lib.sh
BUS_ADDR=10
PORT_COUNT=4
+VF_COUNT=4
DEV_NAME=netdevsim$BUS_ADDR
SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV_NAME/net/
DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV_NAME/
@@ -428,10 +429,60 @@ dummy_reporter_test()
log_test "dummy reporter test"
}
+vdev_attr_get()
+{
+ local handle=$1
+ local name=$2
+
+ cmd_jq "devlink vdev show $handle -j" '.[][].'$name
+}
+
+vdev_objects_get()
+{
+ local handle=$1
+
+ cmd_jq "devlink vdev show -j" \
+ '.[] | keys[] | select(contains("'$handle'"))'
+}
+
+vdev_attr_set()
+{
+ local handle=$1
+ local name=$2
+ local value=$3
+
+ devlink vdev set $handle $name $value
+}
+
+vdev_test()
+{
+ RET=0
+
+ local vdevs=`vdev_objects_get $DL_HANDLE`
+ local num_vdevs=`echo $vdevs | wc -w`
+ [ $num_vdevs == $VF_COUNT ]
+ check_err $? "Expected $VF_COUNT vdevs but got $num_vdevs"
+
+ i=1
+ for vdev in $vdevs
+ do
+ local hw_addr=`printf "10:22:33:44:55:%02x" $i`
+
+ vdev_attr_set "$vdev" hw_addr $hw_addr
+ check_err $? "Failed to set hw_addr value"
+ value=$(vdev_attr_get $vdev hw_addr)
+ check_err $? "Failed to get hw_addr attr value"
+ [ "$value" == "$hw_addr" ]
+ check_err $? "Unexpected hw_addr attr value $value != $hw_addr"
+ i=$(($i+1))
+ done
+ log_test "vdev test"
+}
+
setup_prepare()
{
modprobe netdevsim
- echo "$BUS_ADDR $PORT_COUNT" > /sys/bus/netdevsim/new_device
+ echo "$BUS_ADDR $PORT_COUNT $VF_COUNT" > /sys/bus/netdevsim/new_device
while [ ! -d $SYSFS_NET_DIR ] ; do :; done
}
--
2.17.1
Powered by blists - more mailing lists