Commit e58b43f2 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-ethernet-cortina-use-phylib-for-rx-and-tx-pause'

Linus Walleij says:

====================
net: ethernet: cortina: Use phylib for RX and TX pause

This patch series switches the Cortina Gemini ethernet
driver to use phylib to set up RX and TX pause for the
PHY.

v3: https://lore.kernel.org/r/20240513-gemini-ethernet-fix-tso-v3-0-b442540cc140@linaro.org
v2: https://lore.kernel.org/r/20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org
v1: https://lore.kernel.org/r/20240509-gemini-ethernet-fix-tso-v1-0-10cd07b54d1c@linaro.org
====================

Link: https://lore.kernel.org/r/20240529-gemini-phylib-fixes-v4-0-16487ca4c2fe@linaro.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 5086e1b7 dbdb0918
Loading
Loading
Loading
Loading
+21 −12
Original line number Diff line number Diff line
@@ -288,13 +288,13 @@ static void gmac_set_flow_control(struct net_device *netdev, bool tx, bool rx)
	spin_unlock_irqrestore(&port->config_lock, flags);
}

static void gmac_speed_set(struct net_device *netdev)
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_speed_set(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);
@@ -367,7 +362,7 @@ static int gmac_setup_phy(struct net_device *netdev)

	phy = of_phy_get_and_connect(netdev,
				     dev->of_node,
				     gmac_speed_set);
				     gmac_adjust_link);
	if (!phy)
		return -ENODEV;
	netdev->phydev = phy;
@@ -2131,6 +2126,19 @@ static void gmac_get_pauseparam(struct net_device *netdev,
	pparam->autoneg = true;
}

static int gmac_set_pauseparam(struct net_device *netdev,
			       struct ethtool_pauseparam *pparam)
{
	struct phy_device *phydev = netdev->phydev;

	if (!pparam->autoneg)
		return -EOPNOTSUPP;

	phy_set_asym_pause(phydev, pparam->rx_pause, pparam->tx_pause);

	return 0;
}

static void gmac_get_ringparam(struct net_device *netdev,
			       struct ethtool_ringparam *rp,
			       struct kernel_ethtool_ringparam *kernel_rp,
@@ -2251,6 +2259,7 @@ static const struct ethtool_ops gmac_351x_ethtool_ops = {
	.set_link_ksettings = gmac_set_ksettings,
	.nway_reset	= gmac_nway_reset,
	.get_pauseparam	= gmac_get_pauseparam,
	.set_pauseparam = gmac_set_pauseparam,
	.get_ringparam	= gmac_get_ringparam,
	.set_ringparam	= gmac_set_ringparam,
	.get_coalesce	= gmac_get_coalesce,