Commit 462a94ec authored by David S. Miller's avatar David S. Miller

Merge branch 'phylib-fixed-speed-1G'

Russell King says:

====================
net: phylib: fix fixed-speed >= 1G

This is v2 of the patch (now patches) adding support for ethtool
!autoneg while respecting the requirements of IEEE 802.3.

v2 fixes the build errors in the previous patch by first constifying
the "advertisement" argument to the linkmode functions that only
read from this pointer. It also fixes the incorrectly named
linkmode_set function.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4efee05f 6ff3cddc
......@@ -2108,22 +2108,20 @@ EXPORT_SYMBOL(phy_reset_after_clk_enable);
/**
* genphy_config_advert - sanitize and advertise auto-negotiation parameters
* @phydev: target phy_device struct
* @advert: auto-negotiation parameters to advertise
*
* Description: Writes MII_ADVERTISE with the appropriate values,
* after sanitizing the values to make sure we only advertise
* what is supported. Returns < 0 on error, 0 if the PHY's advertisement
* hasn't changed, and > 0 if it has changed.
*/
static int genphy_config_advert(struct phy_device *phydev)
static int genphy_config_advert(struct phy_device *phydev,
const unsigned long *advert)
{
int err, bmsr, changed = 0;
u32 adv;
/* Only allow advertising what this PHY supports */
linkmode_and(phydev->advertising, phydev->advertising,
phydev->supported);
adv = linkmode_adv_to_mii_adv_t(phydev->advertising);
adv = linkmode_adv_to_mii_adv_t(advert);
/* Setup standard advertisement */
err = phy_modify_changed(phydev, MII_ADVERTISE,
......@@ -2146,7 +2144,7 @@ static int genphy_config_advert(struct phy_device *phydev)
if (!(bmsr & BMSR_ESTATEN))
return changed;
adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising);
adv = linkmode_adv_to_mii_ctrl1000_t(advert);
err = phy_modify_changed(phydev, MII_CTRL1000,
ADVERTISE_1000FULL | ADVERTISE_1000HALF,
......@@ -2370,6 +2368,9 @@ EXPORT_SYMBOL(genphy_check_and_restart_aneg);
*/
int __genphy_config_aneg(struct phy_device *phydev, bool changed)
{
__ETHTOOL_DECLARE_LINK_MODE_MASK(fixed_advert);
const struct phy_setting *set;
unsigned long *advert;
int err;
err = genphy_c45_an_config_eee_aneg(phydev);
......@@ -2384,10 +2385,25 @@ int __genphy_config_aneg(struct phy_device *phydev, bool changed)
else if (err)
changed = true;
if (AUTONEG_ENABLE != phydev->autoneg)
if (phydev->autoneg == AUTONEG_ENABLE) {
/* Only allow advertising what this PHY supports */
linkmode_and(phydev->advertising, phydev->advertising,
phydev->supported);
advert = phydev->advertising;
} else if (phydev->speed < SPEED_1000) {
return genphy_setup_forced(phydev);
} else {
linkmode_zero(fixed_advert);
set = phy_lookup_setting(phydev->speed, phydev->duplex,
phydev->supported, true);
if (set)
linkmode_set_bit(set->bit, fixed_advert);
advert = fixed_advert;
}
err = genphy_config_advert(phydev);
err = genphy_config_advert(phydev, advert);
if (err < 0) /* error */
return err;
else if (err)
......
......@@ -140,7 +140,7 @@ static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv)
* settings to phy autonegotiation advertisements for the
* MII_ADVERTISE register.
*/
static inline u32 linkmode_adv_to_mii_adv_t(unsigned long *advertising)
static inline u32 linkmode_adv_to_mii_adv_t(const unsigned long *advertising)
{
u32 result = 0;
......@@ -215,7 +215,8 @@ static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv)
* settings to phy autonegotiation advertisements for the
* MII_CTRL1000 register when in 1000T mode.
*/
static inline u32 linkmode_adv_to_mii_ctrl1000_t(unsigned long *advertising)
static inline u32
linkmode_adv_to_mii_ctrl1000_t(const unsigned long *advertising)
{
u32 result = 0;
......@@ -453,7 +454,7 @@ static inline void mii_ctrl1000_mod_linkmode_adv_t(unsigned long *advertising,
* A small helper function that translates linkmode advertising to LVL
* pause capabilities.
*/
static inline u32 linkmode_adv_to_lcl_adv_t(unsigned long *advertising)
static inline u32 linkmode_adv_to_lcl_adv_t(const unsigned long *advertising)
{
u32 lcl_adv = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment