Skip to content

Commit f655418

Browse files
Russell Kingdavem330
authored andcommitted
net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant
Add a LPA to linkmode decoder for 1000BASE-X protocols; this decoder only provides the modify semantics similar to other such decoders. This replaces the unused mii_lpa_to_ethtool_lpa_x() helper. Signed-off-by: Russell King <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5d0ab06 commit f655418

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

include/linux/mii.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -354,24 +354,6 @@ static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
354354
return result;
355355
}
356356

357-
/**
358-
* mii_lpa_to_ethtool_lpa_x
359-
* @adv: value of the MII_LPA register
360-
*
361-
* A small helper function that translates MII_LPA
362-
* bits, when in 1000Base-X mode, to ethtool
363-
* LP advertisement settings.
364-
*/
365-
static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa)
366-
{
367-
u32 result = 0;
368-
369-
if (lpa & LPA_LPACK)
370-
result |= ADVERTISED_Autoneg;
371-
372-
return result | mii_adv_to_ethtool_adv_x(lpa);
373-
}
374-
375357
/**
376358
* mii_lpa_mod_linkmode_adv_sgmii
377359
* @lp_advertising: pointer to destination link mode.
@@ -535,6 +517,25 @@ static inline u32 linkmode_adv_to_lcl_adv_t(unsigned long *advertising)
535517
return lcl_adv;
536518
}
537519

520+
/**
521+
* mii_lpa_mod_linkmode_x - decode the link partner's config_reg to linkmodes
522+
* @linkmodes: link modes array
523+
* @lpa: config_reg word from link partner
524+
* @fd_bit: link mode for 1000XFULL bit
525+
*/
526+
static inline void mii_lpa_mod_linkmode_x(unsigned long *linkmodes, u16 lpa,
527+
int fd_bit)
528+
{
529+
linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, linkmodes,
530+
lpa & LPA_LPACK);
531+
linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes,
532+
lpa & LPA_1000XPAUSE);
533+
linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, linkmodes,
534+
lpa & LPA_1000XPAUSE_ASYM);
535+
linkmode_mod_bit(fd_bit, linkmodes,
536+
lpa & LPA_1000XFULL);
537+
}
538+
538539
/**
539540
* mii_advertise_flowctrl - get flow control advertisement flags
540541
* @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)

0 commit comments

Comments
 (0)