From 9fb74734f4f896c03e1ce31278b2d4f8fe2ac033 Mon Sep 17 00:00:00 2001 From: Shalom Toledo Date: Thu, 27 Feb 2020 08:50:16 +0100 Subject: selftests: devlink_lib: Add devlink port helpers Add two devlink port helpers: * devlink port get by netdev * devlink cpu port get Signed-off-by: Shalom Toledo Signed-off-by: Ido Schimmel Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- tools/testing/selftests/net/forwarding/devlink_lib.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tools') diff --git a/tools/testing/selftests/net/forwarding/devlink_lib.sh b/tools/testing/selftests/net/forwarding/devlink_lib.sh index 07e360e2f275..0df6d8942721 100644 --- a/tools/testing/selftests/net/forwarding/devlink_lib.sh +++ b/tools/testing/selftests/net/forwarding/devlink_lib.sh @@ -419,3 +419,19 @@ devlink_trap_drop_cleanup() kill $mz_pid && wait $mz_pid &> /dev/null tc filter del dev $dev egress protocol $proto pref $pref handle $handle flower } + +devlink_port_by_netdev() +{ + local if_name=$1 + + devlink -j port show $if_name | jq -e '.[] | keys' | jq -r '.[]' +} + +devlink_cpu_port_get() +{ + local cpu_dl_port_num=$(devlink port list | grep "$DEVLINK_DEV" | + grep cpu | cut -d/ -f3 | cut -d: -f1 | + sed -n '1p') + + echo "$DEVLINK_DEV/$cpu_dl_port_num" +} -- cgit v1.2.3