Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22b7d299 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller
Browse files

net: ethernet: Add helper to determine if pause configuration is supported



Rather than have MAC drivers open code the test, add a helper in
phylib. This will help when we change the type of phydev->supported.

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0c122405
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -312,9 +312,7 @@ static int xgene_set_pauseparam(struct net_device *ndev,
		if (!phydev)
			return -EINVAL;

		if (!(phydev->supported & SUPPORTED_Pause) ||
		    (!(phydev->supported & SUPPORTED_Asym_Pause) &&
		     pp->rx_pause != pp->tx_pause))
		if (!phy_validate_pause(phydev, pp))
			return -EINVAL;

		pdata->pause_autoneg = pp->autoneg;
+1 −3
Original line number Diff line number Diff line
@@ -12496,9 +12496,7 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam

		phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);

		if (!(phydev->supported & SUPPORTED_Pause) ||
		    (!(phydev->supported & SUPPORTED_Asym_Pause) &&
		     (epause->rx_pause != epause->tx_pause)))
		if (!phy_validate_pause(phydev, epause))
			return -EINVAL;

		tp->link_config.flowctrl = 0;
+1 −3
Original line number Diff line number Diff line
@@ -194,9 +194,7 @@ static int dpaa_set_pauseparam(struct net_device *net_dev,
		return -ENODEV;
	}

	if (!(phydev->supported & SUPPORTED_Pause) ||
	    (!(phydev->supported & SUPPORTED_Asym_Pause) &&
	    (epause->rx_pause != epause->tx_pause)))
	if (!phy_validate_pause(phydev, epause))
		return -EINVAL;

	/* The MAC should know how to handle PAUSE frame autonegotiation before
+1 −3
Original line number Diff line number Diff line
@@ -507,9 +507,7 @@ static int gfar_spauseparam(struct net_device *dev,
	if (!phydev)
		return -ENODEV;

	if (!(phydev->supported & SUPPORTED_Pause) ||
	    (!(phydev->supported & SUPPORTED_Asym_Pause) &&
	     (epause->rx_pause != epause->tx_pause)))
	if (!phy_validate_pause(phydev, epause))
		return -EINVAL;

	priv->rx_pause_en = priv->tx_pause_en = 0;
+20 −0
Original line number Diff line number Diff line
@@ -1863,6 +1863,26 @@ void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx)
}
EXPORT_SYMBOL(phy_set_asym_pause);

/**
 * phy_validate_pause - Test if the PHY/MAC support the pause configuration
 * @phydev: phy_device struct
 * @pp: requested pause configuration
 *
 * Description: Test if the PHY/MAC combination supports the Pause
 * configuration the user is requesting. Returns True if it is
 * supported, false otherwise.
 */
bool phy_validate_pause(struct phy_device *phydev,
			struct ethtool_pauseparam *pp)
{
	if (!(phydev->supported & SUPPORTED_Pause) ||
	    (!(phydev->supported & SUPPORTED_Asym_Pause) &&
	     pp->rx_pause != pp->tx_pause))
		return false;
	return true;
}
EXPORT_SYMBOL(phy_validate_pause);

static void of_set_phy_supported(struct phy_device *phydev)
{
	struct device_node *node = phydev->mdio.dev.of_node;
Loading