Skip to content

Commit

Permalink
net: phylink: Export phylink_caps_to_linkmodes
Browse files Browse the repository at this point in the history
This function is convenient for MAC drivers. They can use it to add or
remove particular link modes based on capabilities (such as if half
duplex is not supported for a particular interface mode).

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sean Anderson authored and David S. Miller committed Sep 23, 2022
1 parent 72bc369 commit 6061165
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/net/phy/phylink.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,15 @@ static const char *phylink_an_mode_str(unsigned int mode)
return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown";
}

static void phylink_caps_to_linkmodes(unsigned long *linkmodes,
unsigned long caps)
/**
* phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes
* @linkmodes: ethtool linkmode mask (must be already initialised)
* @caps: bitmask of MAC capabilities
*
* Set all possible pause, speed and duplex linkmodes in @linkmodes that are
* supported by the @caps. @linkmodes must have been initialised previously.
*/
void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps)
{
if (caps & MAC_SYM_PAUSE)
__set_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes);
Expand Down Expand Up @@ -295,6 +302,7 @@ static void phylink_caps_to_linkmodes(unsigned long *linkmodes,
__set_bit(ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT, linkmodes);
}
}
EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes);

/**
* phylink_get_linkmodes() - get acceptable link modes
Expand Down
1 change: 1 addition & 0 deletions include/linux/phylink.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface, int speed, int duplex);
#endif

void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps);
void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface,
unsigned long mac_capabilities);
void phylink_generic_validate(struct phylink_config *config,
Expand Down

0 comments on commit 6061165

Please sign in to comment.