Skip to content

Commit 667daed

Browse files
Gal Pressmandavem330
authored andcommitted
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: Gal Pressman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cb3c7fd commit 667daed

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
191191
{
192192
struct mlx5e_priv *priv = netdev_priv(dev);
193193
struct mlx5_core_dev *mdev = priv->mdev;
194-
enum mlx5_port_status ps;
195194
u8 curr_pfc_en;
196195
int ret;
197196

@@ -200,14 +199,8 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
200199
if (pfc->pfc_en == curr_pfc_en)
201200
return 0;
202201

203-
mlx5_query_port_admin_status(mdev, &ps);
204-
if (ps == MLX5_PORT_UP)
205-
mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
206-
207202
ret = mlx5_set_port_pfc(mdev, pfc->pfc_en, pfc->pfc_en);
208-
209-
if (ps == MLX5_PORT_UP)
210-
mlx5_set_port_admin_status(mdev, MLX5_PORT_UP);
203+
mlx5_toggle_port_link(mdev);
211204

212205
return ret;
213206
}

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ static int mlx5e_set_settings(struct net_device *netdev,
795795
u32 link_modes;
796796
u32 speed;
797797
u32 eth_proto_cap, eth_proto_admin;
798-
enum mlx5_port_status ps;
799798
int err;
800799

801800
speed = ethtool_cmd_speed(cmd);
@@ -829,12 +828,8 @@ static int mlx5e_set_settings(struct net_device *netdev,
829828
if (link_modes == eth_proto_admin)
830829
goto out;
831830

832-
mlx5_query_port_admin_status(mdev, &ps);
833-
if (ps == MLX5_PORT_UP)
834-
mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
835831
mlx5_set_port_proto(mdev, link_modes, MLX5_PTYS_EN);
836-
if (ps == MLX5_PORT_UP)
837-
mlx5_set_port_admin_status(mdev, MLX5_PORT_UP);
832+
mlx5_toggle_port_link(mdev);
838833

839834
out:
840835
return err;

drivers/net/ethernet/mellanox/mlx5/core/port.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,18 @@ int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
222222
}
223223
EXPORT_SYMBOL_GPL(mlx5_set_port_proto);
224224

225+
/* This function should be used after setting a port register only */
226+
void mlx5_toggle_port_link(struct mlx5_core_dev *dev)
227+
{
228+
enum mlx5_port_status ps;
229+
230+
mlx5_query_port_admin_status(dev, &ps);
231+
mlx5_set_port_admin_status(dev, MLX5_PORT_DOWN);
232+
if (ps == MLX5_PORT_UP)
233+
mlx5_set_port_admin_status(dev, MLX5_PORT_UP);
234+
}
235+
EXPORT_SYMBOL_GPL(mlx5_toggle_port_link);
236+
225237
int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
226238
enum mlx5_port_status status)
227239
{

include/linux/mlx5/port.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ int mlx5_query_port_proto_oper(struct mlx5_core_dev *dev,
6767
u8 local_port);
6868
int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
6969
int proto_mask);
70+
void mlx5_toggle_port_link(struct mlx5_core_dev *dev);
7071
int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
7172
enum mlx5_port_status status);
7273
int mlx5_query_port_admin_status(struct mlx5_core_dev *dev,

0 commit comments

Comments
 (0)