Commit 667daeda authored by Gal Pressman's avatar Gal Pressman Committed by David S. Miller

net/mlx5e: Toggle link only after modifying port parameters

Add a dedicated function to toggle port link. It should be called only
after setting a port register.
Toggle will set port link to down and bring it back up in case that it's
admin status was up.
Signed-off-by: default avatarGal Pressman <galp@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb3c7fd4
...@@ -191,7 +191,6 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev, ...@@ -191,7 +191,6 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
enum mlx5_port_status ps;
u8 curr_pfc_en; u8 curr_pfc_en;
int ret; int ret;
...@@ -200,14 +199,8 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev, ...@@ -200,14 +199,8 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
if (pfc->pfc_en == curr_pfc_en) if (pfc->pfc_en == curr_pfc_en)
return 0; return 0;
mlx5_query_port_admin_status(mdev, &ps);
if (ps == MLX5_PORT_UP)
mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
ret = mlx5_set_port_pfc(mdev, pfc->pfc_en, pfc->pfc_en); ret = mlx5_set_port_pfc(mdev, pfc->pfc_en, pfc->pfc_en);
mlx5_toggle_port_link(mdev);
if (ps == MLX5_PORT_UP)
mlx5_set_port_admin_status(mdev, MLX5_PORT_UP);
return ret; return ret;
} }
......
...@@ -795,7 +795,6 @@ static int mlx5e_set_settings(struct net_device *netdev, ...@@ -795,7 +795,6 @@ static int mlx5e_set_settings(struct net_device *netdev,
u32 link_modes; u32 link_modes;
u32 speed; u32 speed;
u32 eth_proto_cap, eth_proto_admin; u32 eth_proto_cap, eth_proto_admin;
enum mlx5_port_status ps;
int err; int err;
speed = ethtool_cmd_speed(cmd); speed = ethtool_cmd_speed(cmd);
...@@ -829,12 +828,8 @@ static int mlx5e_set_settings(struct net_device *netdev, ...@@ -829,12 +828,8 @@ static int mlx5e_set_settings(struct net_device *netdev,
if (link_modes == eth_proto_admin) if (link_modes == eth_proto_admin)
goto out; goto out;
mlx5_query_port_admin_status(mdev, &ps);
if (ps == MLX5_PORT_UP)
mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
mlx5_set_port_proto(mdev, link_modes, MLX5_PTYS_EN); mlx5_set_port_proto(mdev, link_modes, MLX5_PTYS_EN);
if (ps == MLX5_PORT_UP) mlx5_toggle_port_link(mdev);
mlx5_set_port_admin_status(mdev, MLX5_PORT_UP);
out: out:
return err; return err;
......
...@@ -222,6 +222,18 @@ int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin, ...@@ -222,6 +222,18 @@ int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
} }
EXPORT_SYMBOL_GPL(mlx5_set_port_proto); EXPORT_SYMBOL_GPL(mlx5_set_port_proto);
/* This function should be used after setting a port register only */
void mlx5_toggle_port_link(struct mlx5_core_dev *dev)
{
enum mlx5_port_status ps;
mlx5_query_port_admin_status(dev, &ps);
mlx5_set_port_admin_status(dev, MLX5_PORT_DOWN);
if (ps == MLX5_PORT_UP)
mlx5_set_port_admin_status(dev, MLX5_PORT_UP);
}
EXPORT_SYMBOL_GPL(mlx5_toggle_port_link);
int mlx5_set_port_admin_status(struct mlx5_core_dev *dev, int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
enum mlx5_port_status status) enum mlx5_port_status status)
{ {
......
...@@ -67,6 +67,7 @@ int mlx5_query_port_proto_oper(struct mlx5_core_dev *dev, ...@@ -67,6 +67,7 @@ int mlx5_query_port_proto_oper(struct mlx5_core_dev *dev,
u8 local_port); u8 local_port);
int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin, int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
int proto_mask); int proto_mask);
void mlx5_toggle_port_link(struct mlx5_core_dev *dev);
int mlx5_set_port_admin_status(struct mlx5_core_dev *dev, int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
enum mlx5_port_status status); enum mlx5_port_status status);
int mlx5_query_port_admin_status(struct mlx5_core_dev *dev, int mlx5_query_port_admin_status(struct mlx5_core_dev *dev,
......
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