]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: ethernet: Add helper for set_pauseparam for Pause
authorAndrew Lunn <andrew@lunn.ch>
Tue, 11 Sep 2018 23:53:18 +0000 (01:53 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Sep 2018 03:24:21 +0000 (20:24 -0700)
ethtool can be used to enable/disable pause. Add a helper to configure
the PHY when Pause is supported.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bcm63xx_enet.c
drivers/net/ethernet/freescale/fec_main.c
drivers/net/phy/phy_device.c
include/linux/phy.h

index 9f25667c38e6b98cd043d2162ba4b000ccbe9828..02e7dfc1a2efa94d8f8b92fbe312fe3a92260ce7 100644 (file)
@@ -892,11 +892,8 @@ static int bcm_enet_open(struct net_device *dev)
                /* mask with MAC supported features */
                phy_support_sym_pause(phydev);
                phy_set_max_speed(phydev, SPEED_100);
-
-               if (priv->pause_auto && priv->pause_rx && priv->pause_tx)
-                       phydev->advertising |= SUPPORTED_Pause;
-               else
-                       phydev->advertising &= ~SUPPORTED_Pause;
+               phy_set_sym_pause(phydev, priv->pause_rx, priv->pause_rx,
+                                 priv->pause_auto);
 
                phy_attached_info(phydev);
 
index 05ce0903391aa1fe4528ecd3d7cf4ede6aaff394..2e0bb90131b6e2d03ec9b080f07ef13a947c8c32 100644 (file)
@@ -2229,13 +2229,8 @@ static int fec_enet_set_pauseparam(struct net_device *ndev,
        fep->pause_flag |= pause->rx_pause ? FEC_PAUSE_FLAG_ENABLE : 0;
        fep->pause_flag |= pause->autoneg ? FEC_PAUSE_FLAG_AUTONEG : 0;
 
-       if (pause->rx_pause || pause->autoneg) {
-               ndev->phydev->supported |= ADVERTISED_Pause;
-               ndev->phydev->advertising |= ADVERTISED_Pause;
-       } else {
-               ndev->phydev->supported &= ~ADVERTISED_Pause;
-               ndev->phydev->advertising &= ~ADVERTISED_Pause;
-       }
+       phy_set_sym_pause(ndev->phydev, pause->rx_pause, pause->tx_pause,
+                         pause->autoneg);
 
        if (pause->autoneg) {
                if (netif_running(ndev))
index 5732d89c8e372119383b8fc4802f235a47d10d6a..de95f1e072e9e17b8a3fcaee8c332ad5ed567892 100644 (file)
@@ -1810,6 +1810,29 @@ void phy_support_asym_pause(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(phy_support_asym_pause);
 
+/**
+ * phy_set_sym_pause - Configure symmetric Pause
+ * @phydev: target phy_device struct
+ * @rx: Receiver Pause is supported
+ * @tx: Transmit Pause is supported
+ * @autoneg: Auto neg should be used
+ *
+ * Description: Configure advertised Pause support depending on if
+ * receiver pause and pause auto neg is supported. Generally called
+ * from the set_pauseparam .ndo.
+ */
+void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx,
+                      bool autoneg)
+{
+       phydev->supported &= ~SUPPORTED_Pause;
+
+       if (rx && tx && autoneg)
+               phydev->supported |= SUPPORTED_Pause;
+
+       phydev->advertising = phydev->supported;
+}
+EXPORT_SYMBOL(phy_set_sym_pause);
+
 /**
  * phy_set_asym_pause - Configure Pause and Asym Pause
  * @phydev: target phy_device struct
index e4062ba7472f69f6af4a04525bad723a3385b376..8521391ebb2010f8a987f0cd5c26863907fc85db 100644 (file)
@@ -1052,6 +1052,8 @@ int phy_set_max_speed(struct phy_device *phydev, u32 max_speed);
 void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode);
 void phy_support_sym_pause(struct phy_device *phydev);
 void phy_support_asym_pause(struct phy_device *phydev);
+void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx,
+                      bool autoneg);
 void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx);
 
 int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,