]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: lan743x: Add support for get_pauseparam and set_pauseparam
authorRaju Lakkaraju <Raju.Lakkaraju@microchip.com>
Mon, 24 Oct 2022 08:25:15 +0000 (13:55 +0530)
committerJakub Kicinski <kuba@kernel.org>
Tue, 25 Oct 2022 23:08:59 +0000 (16:08 -0700)
Add pause get and set functions

Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/lan743x_ethtool.c
drivers/net/ethernet/microchip/lan743x_main.c
drivers/net/ethernet/microchip/lan743x_main.h

index c739d60ee17d5cfc0975d07ecf704eb5eb2ac559..88f9484cc2a71c6802c4f067c72c724dd70dc74c 100644 (file)
@@ -1233,6 +1233,50 @@ static void lan743x_get_regs(struct net_device *dev,
        lan743x_common_regs(dev, regs, p);
 }
 
+static void lan743x_get_pauseparam(struct net_device *dev,
+                                  struct ethtool_pauseparam *pause)
+{
+       struct lan743x_adapter *adapter = netdev_priv(dev);
+       struct lan743x_phy *phy = &adapter->phy;
+
+       if (phy->fc_request_control & FLOW_CTRL_TX)
+               pause->tx_pause = 1;
+       if (phy->fc_request_control & FLOW_CTRL_RX)
+               pause->rx_pause = 1;
+       pause->autoneg = phy->fc_autoneg;
+}
+
+static int lan743x_set_pauseparam(struct net_device *dev,
+                                 struct ethtool_pauseparam *pause)
+{
+       struct lan743x_adapter *adapter = netdev_priv(dev);
+       struct phy_device *phydev = dev->phydev;
+       struct lan743x_phy *phy = &adapter->phy;
+
+       if (!phydev)
+               return -ENODEV;
+
+       if (!phy_validate_pause(phydev, pause))
+               return -EINVAL;
+
+       phy->fc_request_control = 0;
+       if (pause->rx_pause)
+               phy->fc_request_control |= FLOW_CTRL_RX;
+
+       if (pause->tx_pause)
+               phy->fc_request_control |= FLOW_CTRL_TX;
+
+       phy->fc_autoneg = pause->autoneg;
+
+       if (pause->autoneg == AUTONEG_DISABLE)
+               lan743x_mac_flow_ctrl_set_enables(adapter, pause->tx_pause,
+                                                 pause->rx_pause);
+       else
+               phy_set_asym_pause(phydev, pause->rx_pause,  pause->tx_pause);
+
+       return 0;
+}
+
 const struct ethtool_ops lan743x_ethtool_ops = {
        .get_drvinfo = lan743x_ethtool_get_drvinfo,
        .get_msglevel = lan743x_ethtool_get_msglevel,
@@ -1259,6 +1303,8 @@ const struct ethtool_ops lan743x_ethtool_ops = {
        .set_link_ksettings = phy_ethtool_set_link_ksettings,
        .get_regs_len = lan743x_get_regs_len,
        .get_regs = lan743x_get_regs,
+       .get_pauseparam = lan743x_get_pauseparam,
+       .set_pauseparam = lan743x_set_pauseparam,
 #ifdef CONFIG_PM
        .get_wol = lan743x_ethtool_get_wol,
        .set_wol = lan743x_ethtool_set_wol,
index 50eeecba1f18d1586c77642437f4a7f8f12585d5..c0f8ba601c01327020c6160f6ff756783ae6cb59 100644 (file)
@@ -1326,8 +1326,8 @@ static void lan743x_mac_close(struct lan743x_adapter *adapter)
                                 1, 1000, 20000, 100);
 }
 
-static void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter,
-                                             bool tx_enable, bool rx_enable)
+void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter,
+                                      bool tx_enable, bool rx_enable)
 {
        u32 flow_setting = 0;
 
index 67877d3b6dd9842308401063e20ffc00aeea4df7..bc5eea4c7b40003b901a5e01e7c77ca14a93e48b 100644 (file)
@@ -1159,5 +1159,7 @@ u32 lan743x_csr_read(struct lan743x_adapter *adapter, int offset);
 void lan743x_csr_write(struct lan743x_adapter *adapter, int offset, u32 data);
 int lan743x_hs_syslock_acquire(struct lan743x_adapter *adapter, u16 timeout);
 void lan743x_hs_syslock_release(struct lan743x_adapter *adapter);
+void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter,
+                                      bool tx_enable, bool rx_enable);
 
 #endif /* _LAN743X_H */