diff options
author | Jiri Pirko <jiri@mellanox.com> | 2019-04-03 14:24:17 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-04 17:42:36 -0700 |
commit | 7e1146e8c10c00f859843817da8ecc5d902ea409 (patch) | |
tree | 822a020b5a501b08faa86b25488bc07c46af7db7 /net/core/dev.c | |
parent | bec5267cded268acdf679b651778c300d204e9f2 (diff) | |
download | linux-7e1146e8c10c00f859843817da8ecc5d902ea409.tar.gz linux-7e1146e8c10c00f859843817da8ecc5d902ea409.tar.bz2 linux-7e1146e8c10c00f859843817da8ecc5d902ea409.zip |
net: devlink: introduce devlink_compat_switch_id_get() helper
Introduce devlink_compat_switch_id_get() helper which fills up switch_id
according to passed netdev pointer. Call it directly from
dev_get_port_parent_id() as a fallback when ndo_get_port_parent_id
is not defined for given netdev.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 79e0c26988b8..a95782764360 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -7900,13 +7900,20 @@ int dev_get_port_parent_id(struct net_device *dev, struct netdev_phys_item_id first = { }; struct net_device *lower_dev; struct list_head *iter; - int err = -EOPNOTSUPP; + int err; + + if (ops->ndo_get_port_parent_id) { + err = ops->ndo_get_port_parent_id(dev, ppid); + if (err != -EOPNOTSUPP) + return err; + } - if (ops->ndo_get_port_parent_id) - return ops->ndo_get_port_parent_id(dev, ppid); + err = devlink_compat_switch_id_get(dev, ppid); + if (!err || err != -EOPNOTSUPP) + return err; if (!recurse) - return err; + return -EOPNOTSUPP; netdev_for_each_lower_dev(dev, lower_dev, iter) { err = dev_get_port_parent_id(lower_dev, ppid, recurse); |