net/mlx5e: Toggle link only after modifying port parameters
authorGal Pressman <galp@mellanox.com>
Thu, 23 Jun 2016 14:02:42 +0000 (17:02 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Jun 2016 08:10:41 +0000 (04:10 -0400)
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 <galp@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/mellanox/mlx5/core/port.c
include/linux/mlx5/port.h

index b2db180ae2a5bbdda29219d63c72feea0958c12c..e6883132b555b2855b24e9f1d488ec7a9b83852a 100644 (file)
@@ -191,7 +191,6 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
        struct mlx5_core_dev *mdev = priv->mdev;
-       enum mlx5_port_status ps;
        u8 curr_pfc_en;
        int ret;
 
@@ -200,14 +199,8 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
        if (pfc->pfc_en == curr_pfc_en)
                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);
-
-       if (ps == MLX5_PORT_UP)
-               mlx5_set_port_admin_status(mdev, MLX5_PORT_UP);
+       mlx5_toggle_port_link(mdev);
 
        return ret;
 }
index c4be3941957ec23eb5f05a721bf2165ad12eaf81..d0d3dcfb4de9a7edd38af0a019c2f687edadbc0a 100644 (file)
@@ -795,7 +795,6 @@ static int mlx5e_set_settings(struct net_device *netdev,
        u32 link_modes;
        u32 speed;
        u32 eth_proto_cap, eth_proto_admin;
-       enum mlx5_port_status ps;
        int err;
 
        speed = ethtool_cmd_speed(cmd);
@@ -829,12 +828,8 @@ static int mlx5e_set_settings(struct net_device *netdev,
        if (link_modes == eth_proto_admin)
                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);
-       if (ps == MLX5_PORT_UP)
-               mlx5_set_port_admin_status(mdev, MLX5_PORT_UP);
+       mlx5_toggle_port_link(mdev);
 
 out:
        return err;
index 3e35611b19c30d05bc5530f06cab49743f9aa102..1562e7310f5b7a20a19dffb261f4ab970c0b8bfc 100644 (file)
@@ -222,6 +222,18 @@ int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
 }
 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,
                               enum mlx5_port_status status)
 {
index 9851862c0ec5e40f13af1706d8b5b5db3335e18b..4adfac15f0e933aa6a9fc85abaa2991ed821e500 100644 (file)
@@ -67,6 +67,7 @@ int mlx5_query_port_proto_oper(struct mlx5_core_dev *dev,
                               u8 local_port);
 int mlx5_set_port_proto(struct mlx5_core_dev *dev, u32 proto_admin,
                        int proto_mask);
+void mlx5_toggle_port_link(struct mlx5_core_dev *dev);
 int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
                               enum mlx5_port_status status);
 int mlx5_query_port_admin_status(struct mlx5_core_dev *dev,