aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2019-03-28 08:56:37 -0400
committerDavid S. Miller <davem@davemloft.net>2019-03-28 15:55:30 -0400
commitaf3836df9a59e7339d60c9c46729a7d9094d0582 (patch)
tree739ad2a6a871e9ca4fc7bf814b5659f5d82343d8 /net/core/dev.c
parent5dc37bb9b03586e8fdeb47d25e8d2a0399984936 (diff)
net: devlink: introduce devlink_compat_phys_port_name_get()
Introduce devlink_compat_phys_port_name_get() helper that gets the physical port name for specified netdevice according to devlink port attributes. Call this helper from dev_get_phys_port_name() in case ndo_get_phys_port_name is not defined. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 9ca2d3abfd1a..9823b7713f79 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -146,6 +146,7 @@
146#include <net/udp_tunnel.h> 146#include <net/udp_tunnel.h>
147#include <linux/net_namespace.h> 147#include <linux/net_namespace.h>
148#include <linux/indirect_call_wrapper.h> 148#include <linux/indirect_call_wrapper.h>
149#include <net/devlink.h>
149 150
150#include "net-sysfs.h" 151#include "net-sysfs.h"
151 152
@@ -7877,10 +7878,14 @@ int dev_get_phys_port_name(struct net_device *dev,
7877 char *name, size_t len) 7878 char *name, size_t len)
7878{ 7879{
7879 const struct net_device_ops *ops = dev->netdev_ops; 7880 const struct net_device_ops *ops = dev->netdev_ops;
7881 int err;
7880 7882
7881 if (!ops->ndo_get_phys_port_name) 7883 if (ops->ndo_get_phys_port_name) {
7882 return -EOPNOTSUPP; 7884 err = ops->ndo_get_phys_port_name(dev, name, len);
7883 return ops->ndo_get_phys_port_name(dev, name, len); 7885 if (err != -EOPNOTSUPP)
7886 return err;
7887 }
7888 return devlink_compat_phys_port_name_get(dev, name, len);
7884} 7889}
7885EXPORT_SYMBOL(dev_get_phys_port_name); 7890EXPORT_SYMBOL(dev_get_phys_port_name);
7886 7891