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

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

net: phy: Convert u32 phydev->lp_advertising to linkmode



Convert phy drivers to report the link partner advertised modes using
a linkmode bitmap. This allows them to report the higher speeds which
don't fit in a u32.

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3c1bcc86
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ static int lxt973a2_read_status(struct phy_device *phydev)
			*/
		} while (lpa == adv && retry--);

		phydev->lp_advertising = mii_lpa_to_ethtool_lpa_t(lpa);
		mii_lpa_to_linkmode_lpa_t(phydev->lp_advertising, lpa);

		lpa &= adv;

@@ -218,7 +218,7 @@ static int lxt973a2_read_status(struct phy_device *phydev)
			phydev->speed = SPEED_10;

		phydev->pause = phydev->asym_pause = 0;
		phydev->lp_advertising = 0;
		linkmode_zero(phydev->lp_advertising);
	}

	return 0;
+12 −14
Original line number Diff line number Diff line
@@ -1049,22 +1049,21 @@ static int m88e1145_config_init(struct phy_device *phydev)
}

/**
 * fiber_lpa_to_ethtool_lpa_t
 * fiber_lpa_to_linkmode_lpa_t
 * @advertising: the linkmode advertisement settings
 * @lpa: value of the MII_LPA register for fiber link
 *
 * A small helper function that translates MII_LPA
 * bits to ethtool LP advertisement settings.
 * bits to linkmode LP advertisement settings.
 */
static u32 fiber_lpa_to_ethtool_lpa_t(u32 lpa)
static void fiber_lpa_to_linkmode_lpa_t(unsigned long *advertising, u32 lpa)
{
	u32 result = 0;

	if (lpa & LPA_FIBER_1000HALF)
		result |= ADVERTISED_1000baseT_Half;
		linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
				 advertising);
	if (lpa & LPA_FIBER_1000FULL)
		result |= ADVERTISED_1000baseT_Full;

	return result;
		linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
				 advertising);
}

/**
@@ -1140,9 +1139,8 @@ static int marvell_read_status_page_an(struct phy_device *phydev,
	}

	if (!fiber) {
		phydev->lp_advertising =
			mii_stat1000_to_ethtool_lpa_t(lpagb) |
			mii_lpa_to_ethtool_lpa_t(lpa);
		mii_lpa_to_linkmode_lpa_t(phydev->lp_advertising, lpa);
		mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising, lpagb);

		if (phydev->duplex == DUPLEX_FULL) {
			phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
@@ -1150,7 +1148,7 @@ static int marvell_read_status_page_an(struct phy_device *phydev,
		}
	} else {
		/* The fiber link is only 1000M capable */
		phydev->lp_advertising = fiber_lpa_to_ethtool_lpa_t(lpa);
		fiber_lpa_to_linkmode_lpa_t(phydev->lp_advertising, lpa);

		if (phydev->duplex == DUPLEX_FULL) {
			if (!(lpa & LPA_PAUSE_FIBER)) {
@@ -1189,7 +1187,7 @@ static int marvell_read_status_page_fixed(struct phy_device *phydev)

	phydev->pause = 0;
	phydev->asym_pause = 0;
	phydev->lp_advertising = 0;
	linkmode_zero(phydev->lp_advertising);

	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -457,7 +457,7 @@ static int mv3310_read_status(struct phy_device *phydev)

	phydev->speed = SPEED_UNKNOWN;
	phydev->duplex = DUPLEX_UNKNOWN;
	phydev->lp_advertising = 0;
	linkmode_zero(phydev->lp_advertising);
	phydev->link = 0;
	phydev->pause = 0;
	phydev->asym_pause = 0;
@@ -490,7 +490,7 @@ static int mv3310_read_status(struct phy_device *phydev)
		if (val < 0)
			return val;

		phydev->lp_advertising |= mii_stat1000_to_ethtool_lpa_t(val);
		mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising, val);

		if (phydev->autoneg == AUTONEG_ENABLE)
			phy_resolve_aneg_linkmode(phydev);
+3 −2
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ int genphy_c45_read_lpa(struct phy_device *phydev)
	if (val < 0)
		return val;

	phydev->lp_advertising = mii_lpa_to_ethtool_lpa_t(val);
	mii_lpa_to_linkmode_lpa_t(phydev->lp_advertising, val);
	phydev->pause = val & LPA_PAUSE_CAP ? 1 : 0;
	phydev->asym_pause = val & LPA_PAUSE_ASYM ? 1 : 0;

@@ -191,7 +191,8 @@ int genphy_c45_read_lpa(struct phy_device *phydev)
		return val;

	if (val & MDIO_AN_10GBT_STAT_LP10G)
		phydev->lp_advertising |= ADVERTISED_10000baseT_Full;
		linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
				 phydev->lp_advertising);

	return 0;
}
+6 −7
Original line number Diff line number Diff line
@@ -199,11 +199,8 @@ size_t phy_speeds(unsigned int *speeds, size_t size,
void phy_resolve_aneg_linkmode(struct phy_device *phydev)
{
	__ETHTOOL_DECLARE_LINK_MODE_MASK(common);
	__ETHTOOL_DECLARE_LINK_MODE_MASK(lp);

	ethtool_convert_legacy_u32_to_link_mode(lp, phydev->lp_advertising);

	linkmode_and(common, lp, phydev->advertising);
	linkmode_and(common, phydev->lp_advertising, phydev->advertising);

	if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, common)) {
		phydev->speed = SPEED_10000;
@@ -235,9 +232,11 @@ void phy_resolve_aneg_linkmode(struct phy_device *phydev)
	}

	if (phydev->duplex == DUPLEX_FULL) {
		phydev->pause = !!(phydev->lp_advertising & ADVERTISED_Pause);
		phydev->asym_pause = !!(phydev->lp_advertising &
					ADVERTISED_Asym_Pause);
		phydev->pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
						  phydev->lp_advertising);
		phydev->asym_pause = linkmode_test_bit(
			ETHTOOL_LINK_MODE_Asym_Pause_BIT,
			phydev->lp_advertising);
	}
}
EXPORT_SYMBOL_GPL(phy_resolve_aneg_linkmode);
Loading