summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-10-07 09:11:07 -0400
committerDavid S. Miller <davem@davemloft.net>2019-10-07 09:11:07 -0400
commitdb7fe42d687c8df861487f5343f1113a0dc80a85 (patch)
tree1efe2dc30240b8e5346bd24ae091c5e2c0944edf
parent82a843de41d42681c1bbf9194b28736d06050b08 (diff)
parent62ede55fe68c91c92ac7fdd65828c9413155faf6 (diff)
downloadlinux-db7fe42d687c8df861487f5343f1113a0dc80a85.tar.bz2
Merge branch 'netdevsim-implement-devlink-dev_info-op'
Jiri Pirko says: ==================== netdevsim: implement devlink dev_info op Initial implementation of devlink dev_info op - just driver name is filled up and sent to user. Bundled with selftest. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/netdevsim/dev.c8
-rwxr-xr-xtools/testing/selftests/drivers/net/netdevsim/devlink.sh21
2 files changed, 28 insertions, 1 deletions
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 31d1752c703a..a3d7d39f231a 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -510,6 +510,13 @@ static int nsim_dev_reload_up(struct devlink *devlink,
return nsim_dev_reload_create(nsim_dev, extack);
}
+static int nsim_dev_info_get(struct devlink *devlink,
+ struct devlink_info_req *req,
+ struct netlink_ext_ack *extack)
+{
+ return devlink_info_driver_name_put(req, DRV_NAME);
+}
+
#define NSIM_DEV_FLASH_SIZE 500000
#define NSIM_DEV_FLASH_CHUNK_SIZE 1000
#define NSIM_DEV_FLASH_CHUNK_TIME_MS 10
@@ -603,6 +610,7 @@ nsim_dev_devlink_trap_action_set(struct devlink *devlink,
static const struct devlink_ops nsim_dev_devlink_ops = {
.reload_down = nsim_dev_reload_down,
.reload_up = nsim_dev_reload_up,
+ .info_get = nsim_dev_info_get,
.flash_update = nsim_dev_flash_update,
.trap_init = nsim_dev_devlink_trap_init,
.trap_action_set = nsim_dev_devlink_trap_action_set,
diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index de3174431b8e..cb0f17e17abc 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -4,7 +4,7 @@
lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="fw_flash_test params_test regions_test reload_test \
- netns_reload_test resource_test"
+ netns_reload_test resource_test dev_info_test"
NUM_NETIFS=0
source $lib_dir/lib.sh
@@ -284,6 +284,25 @@ resource_test()
log_test "resource test"
}
+info_get()
+{
+ local name=$1
+
+ cmd_jq "devlink dev info $DL_HANDLE -j" ".[][][\"$name\"]" "-e"
+}
+
+dev_info_test()
+{
+ RET=0
+
+ driver=$(info_get "driver")
+ check_err $? "Failed to get driver name"
+ [ "$driver" == "netdevsim" ]
+ check_err $? "Unexpected driver name $driver"
+
+ log_test "dev_info test"
+}
+
setup_prepare()
{
modprobe netdevsim