net: ethernet: cortina: Use negotiated TX/RX pause
authorLinus Walleij <linus.walleij@linaro.org>
Wed, 29 May 2024 14:00:01 +0000 (16:00 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 1 Jun 2024 23:07:29 +0000 (16:07 -0700)
Instead of directly poking into registers of the PHY, use
the existing function to query phylib about this directly.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20240529-gemini-phylib-fixes-v4-2-16487ca4c2fe@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cortina/gemini.c

index 8de68a257611406e5dc7c0706a647111131bbee3..a37d21ceb1318d8403bc83db8ca3b489b67a2828 100644 (file)
@@ -293,8 +293,8 @@ static void gmac_adjust_link(struct net_device *netdev)
        struct gemini_ethernet_port *port = netdev_priv(netdev);
        struct phy_device *phydev = netdev->phydev;
        union gmac_status status, old_status;
-       int pause_tx = 0;
-       int pause_rx = 0;
+       bool pause_tx = false;
+       bool pause_rx = false;
 
        status.bits32 = readl(port->gmac_base + GMAC_STATUS);
        old_status.bits32 = status.bits32;
@@ -329,14 +329,9 @@ static void gmac_adjust_link(struct net_device *netdev)
        }
 
        if (phydev->duplex == DUPLEX_FULL) {
-               u16 lcladv = phy_read(phydev, MII_ADVERTISE);
-               u16 rmtadv = phy_read(phydev, MII_LPA);
-               u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
-
-               if (cap & FLOW_CTRL_RX)
-                       pause_rx = 1;
-               if (cap & FLOW_CTRL_TX)
-                       pause_tx = 1;
+               phy_get_pause(phydev, &pause_tx, &pause_rx);
+               netdev_dbg(netdev, "set negotiated pause params pause TX = %s, pause RX = %s\n",
+                          pause_tx ? "ON" : "OFF", pause_rx ? "ON" : "OFF");
        }
 
        gmac_set_flow_control(netdev, pause_tx, pause_rx);