summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2019-03-28 13:56:46 +0100
committerDavid S. Miller <davem@davemloft.net>2019-03-28 12:55:31 -0700
commit746364f298d48cc89067e6d0c9bc1a4da1efb52a (patch)
tree3a4d5031f135209c4db0a6027e7b983e45caca40 /net/core
parentf1fa719cfd552dccdfe80e6f81be8d15503dfcce (diff)
net: devlink: add warning for ndo_get_phys_port_name set when not needed
Currently if the driver registers devlink port instance, it should set the devlink port attributes as well. Then the devlink core is able to obtain physical port name itself, no need for driver to implement the ndo. Once all drivers will implement devlink port registration, this ndo should be removed. This warning guides new drivers to do things as they should be done. 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')
-rw-r--r--net/core/devlink.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 6bbd07e3861e..dc3a99148ee7 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5358,6 +5358,24 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port,
void devlink_port_type_eth_set(struct devlink_port *devlink_port,
struct net_device *netdev)
{
+ /* If driver registers devlink port, it should set devlink port
+ * attributes accordingly so the compat functions are called
+ * and the original ops are not used.
+ */
+ if (netdev->netdev_ops->ndo_get_phys_port_name) {
+ /* Some drivers use the same set of ndos for netdevs
+ * that have devlink_port registered and also for
+ * those who don't. Make sure that ndo_get_phys_port_name
+ * returns -EOPNOTSUPP here in case it is defined.
+ * Warn if not.
+ */
+ const struct net_device_ops *ops = netdev->netdev_ops;
+ char name[IFNAMSIZ];
+ int err;
+
+ err = ops->ndo_get_phys_port_name(netdev, name, sizeof(name));
+ WARN_ON(err != -EOPNOTSUPP);
+ }
__devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_ETH, netdev);
}
EXPORT_SYMBOL_GPL(devlink_port_type_eth_set);