Commit 31e87b39 authored by Vladyslav Tarasiuk's avatar Vladyslav Tarasiuk Committed by Saeed Mahameed

net/mlx5e: Fix devlink port register sequence

If udevd is configured to rename interfaces according to persistent
naming rules and if a network interface has phys_port_name in sysfs,
its contents will be appended to the interface name.
However, register_netdev creates device in sysfs and if
devlink_port_register is called after that, there is a timeframe in
which udevd may read an empty phys_port_name value. The consequence is
that the interface will lose this suffix and its name will not be
really persistent.

The solution is to register the port before registering a netdev.

Fixes: c6acd629 ("net/mlx5e: Add support for devlink-port in non-representors mode")
Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@mellanox.com>
Reviewed-by: default avatarMaxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent d0645b37
...@@ -3,20 +3,14 @@ ...@@ -3,20 +3,14 @@
#include "en/devlink.h" #include "en/devlink.h"
int mlx5e_devlink_port_register(struct net_device *netdev) int mlx5e_devlink_port_register(struct mlx5e_priv *priv)
{ {
struct mlx5_core_dev *dev; struct devlink *devlink = priv_to_devlink(priv->mdev);
struct mlx5e_priv *priv;
struct devlink *devlink;
int err;
priv = netdev_priv(netdev); if (mlx5_core_is_pf(priv->mdev))
dev = priv->mdev;
if (mlx5_core_is_pf(dev))
devlink_port_attrs_set(&priv->dl_port, devlink_port_attrs_set(&priv->dl_port,
DEVLINK_PORT_FLAVOUR_PHYSICAL, DEVLINK_PORT_FLAVOUR_PHYSICAL,
PCI_FUNC(dev->pdev->devfn), PCI_FUNC(priv->mdev->pdev->devfn),
false, 0, false, 0,
NULL, 0); NULL, 0);
else else
...@@ -24,12 +18,12 @@ int mlx5e_devlink_port_register(struct net_device *netdev) ...@@ -24,12 +18,12 @@ int mlx5e_devlink_port_register(struct net_device *netdev)
DEVLINK_PORT_FLAVOUR_VIRTUAL, DEVLINK_PORT_FLAVOUR_VIRTUAL,
0, false, 0, NULL, 0); 0, false, 0, NULL, 0);
devlink = priv_to_devlink(dev); return devlink_port_register(devlink, &priv->dl_port, 1);
err = devlink_port_register(devlink, &priv->dl_port, 1); }
if (err)
return err; void mlx5e_devlink_port_type_eth_set(struct mlx5e_priv *priv)
devlink_port_type_eth_set(&priv->dl_port, netdev); {
return 0; devlink_port_type_eth_set(&priv->dl_port, priv->netdev);
} }
void mlx5e_devlink_port_unregister(struct mlx5e_priv *priv) void mlx5e_devlink_port_unregister(struct mlx5e_priv *priv)
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
#include <net/devlink.h> #include <net/devlink.h>
#include "en.h" #include "en.h"
int mlx5e_devlink_port_register(struct net_device *dev); int mlx5e_devlink_port_register(struct mlx5e_priv *priv);
void mlx5e_devlink_port_unregister(struct mlx5e_priv *priv); void mlx5e_devlink_port_unregister(struct mlx5e_priv *priv);
void mlx5e_devlink_port_type_eth_set(struct mlx5e_priv *priv);
struct devlink_port *mlx5e_get_devlink_port(struct net_device *dev); struct devlink_port *mlx5e_get_devlink_port(struct net_device *dev);
#endif #endif
...@@ -5467,25 +5467,27 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev) ...@@ -5467,25 +5467,27 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
goto err_destroy_netdev; goto err_destroy_netdev;
} }
err = register_netdev(netdev); err = mlx5e_devlink_port_register(priv);
if (err) { if (err) {
mlx5_core_err(mdev, "register_netdev failed, %d\n", err); mlx5_core_err(mdev, "mlx5e_devlink_port_register failed, %d\n", err);
goto err_detach; goto err_detach;
} }
err = mlx5e_devlink_port_register(netdev); err = register_netdev(netdev);
if (err) { if (err) {
mlx5_core_err(mdev, "mlx5e_devlink_phy_port_register failed, %d\n", err); mlx5_core_err(mdev, "register_netdev failed, %d\n", err);
goto err_unregister_netdev; goto err_devlink_port_unregister;
} }
mlx5e_devlink_port_type_eth_set(priv);
#ifdef CONFIG_MLX5_CORE_EN_DCB #ifdef CONFIG_MLX5_CORE_EN_DCB
mlx5e_dcbnl_init_app(priv); mlx5e_dcbnl_init_app(priv);
#endif #endif
return priv; return priv;
err_unregister_netdev: err_devlink_port_unregister:
unregister_netdev(netdev); mlx5e_devlink_port_unregister(priv);
err_detach: err_detach:
mlx5e_detach(mdev, priv); mlx5e_detach(mdev, priv);
err_destroy_netdev: err_destroy_netdev:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment