net/mlx5e: Fix devlink port register sequence
authorVladyslav Tarasiuk <vladyslavt@mellanox.com>
Wed, 4 Mar 2020 11:33:50 +0000 (13:33 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 18 Mar 2020 02:41:30 +0000 (19:41 -0700)
commit31e87b39ba9d47cf31f5a91dd3cc9680f5987d12
tree409e400a143c1eada31e9b3ecd620742a668e937
parentd0645b3780954b7133d9a908009d166ae686bd2a
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: c6acd629eec7 ("net/mlx5e: Add support for devlink-port in non-representors mode")
Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c