Skip to content

Commit 746364f

Browse files
jpirkodavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f1fa719 commit 746364f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

net/core/devlink.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,6 +5358,24 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port,
53585358
void devlink_port_type_eth_set(struct devlink_port *devlink_port,
53595359
struct net_device *netdev)
53605360
{
5361+
/* If driver registers devlink port, it should set devlink port
5362+
* attributes accordingly so the compat functions are called
5363+
* and the original ops are not used.
5364+
*/
5365+
if (netdev->netdev_ops->ndo_get_phys_port_name) {
5366+
/* Some drivers use the same set of ndos for netdevs
5367+
* that have devlink_port registered and also for
5368+
* those who don't. Make sure that ndo_get_phys_port_name
5369+
* returns -EOPNOTSUPP here in case it is defined.
5370+
* Warn if not.
5371+
*/
5372+
const struct net_device_ops *ops = netdev->netdev_ops;
5373+
char name[IFNAMSIZ];
5374+
int err;
5375+
5376+
err = ops->ndo_get_phys_port_name(netdev, name, sizeof(name));
5377+
WARN_ON(err != -EOPNOTSUPP);
5378+
}
53615379
__devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_ETH, netdev);
53625380
}
53635381
EXPORT_SYMBOL_GPL(devlink_port_type_eth_set);

0 commit comments

Comments
 (0)