Commit b6f97747 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by Jakub Kicinski

net: phylink: provide mac_get_caps() method

Provide a new method, mac_get_caps() to get the MAC capabilities for
the specified interface mode. This is for MACs which have special
requirements, such as not supporting half-duplex in certain interface
modes, and will replace the validate() method.
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/E1qsPk5-009wiX-G5@rmk-PC.armlinux.org.ukSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 73b24e7c
...@@ -200,6 +200,13 @@ this documentation. ...@@ -200,6 +200,13 @@ this documentation.
when the in-band link state changes - otherwise the link will never when the in-band link state changes - otherwise the link will never
come up. come up.
The :c:func:`mac_get_caps` method is optional, and if provided should
return the phylink MAC capabilities that are supported for the passed
``interface`` mode. In general, there is no need to implement this method.
Phylink will use these capabilities in combination with permissible
capabilities for ``interface`` to determine the allowable ethtool link
modes.
The :c:func:`validate` method should mask the supplied supported mask, The :c:func:`validate` method should mask the supplied supported mask,
and ``state->advertising`` with the supported ethtool link modes. and ``state->advertising`` with the supported ethtool link modes.
These are the new ethtool link modes, so bitmask operations must be These are the new ethtool link modes, so bitmask operations must be
......
...@@ -657,6 +657,7 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl, ...@@ -657,6 +657,7 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
unsigned long *supported, unsigned long *supported,
struct phylink_link_state *state) struct phylink_link_state *state)
{ {
unsigned long capabilities;
struct phylink_pcs *pcs; struct phylink_pcs *pcs;
int ret; int ret;
...@@ -696,10 +697,17 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl, ...@@ -696,10 +697,17 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
} }
/* Then validate the link parameters with the MAC */ /* Then validate the link parameters with the MAC */
if (pl->mac_ops->validate) if (pl->mac_ops->validate) {
pl->mac_ops->validate(pl->config, supported, state); pl->mac_ops->validate(pl->config, supported, state);
else } else {
phylink_generic_validate(pl->config, supported, state); if (pl->mac_ops->mac_get_caps)
capabilities = pl->mac_ops->mac_get_caps(pl->config,
state->interface);
else
capabilities = pl->config->mac_capabilities;
phylink_validate_mask_caps(supported, state, capabilities);
}
return phylink_is_empty_linkmode(supported) ? -EINVAL : 0; return phylink_is_empty_linkmode(supported) ? -EINVAL : 0;
} }
......
...@@ -228,6 +228,7 @@ void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed); ...@@ -228,6 +228,7 @@ void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed);
/** /**
* struct phylink_mac_ops - MAC operations structure. * struct phylink_mac_ops - MAC operations structure.
* @validate: Validate and update the link configuration. * @validate: Validate and update the link configuration.
* @mac_get_caps: Get MAC capabilities for interface mode.
* @mac_select_pcs: Select a PCS for the interface mode. * @mac_select_pcs: Select a PCS for the interface mode.
* @mac_prepare: prepare for a major reconfiguration of the interface. * @mac_prepare: prepare for a major reconfiguration of the interface.
* @mac_config: configure the MAC for the selected mode and state. * @mac_config: configure the MAC for the selected mode and state.
...@@ -241,6 +242,8 @@ struct phylink_mac_ops { ...@@ -241,6 +242,8 @@ struct phylink_mac_ops {
void (*validate)(struct phylink_config *config, void (*validate)(struct phylink_config *config,
unsigned long *supported, unsigned long *supported,
struct phylink_link_state *state); struct phylink_link_state *state);
unsigned long (*mac_get_caps)(struct phylink_config *config,
phy_interface_t interface);
struct phylink_pcs *(*mac_select_pcs)(struct phylink_config *config, struct phylink_pcs *(*mac_select_pcs)(struct phylink_config *config,
phy_interface_t interface); phy_interface_t interface);
int (*mac_prepare)(struct phylink_config *config, unsigned int mode, int (*mac_prepare)(struct phylink_config *config, unsigned int mode,
...@@ -292,6 +295,18 @@ struct phylink_mac_ops { ...@@ -292,6 +295,18 @@ struct phylink_mac_ops {
*/ */
void validate(struct phylink_config *config, unsigned long *supported, void validate(struct phylink_config *config, unsigned long *supported,
struct phylink_link_state *state); struct phylink_link_state *state);
/**
* mac_get_caps: Get MAC capabilities for interface mode.
* @config: a pointer to a &struct phylink_config.
* @interface: PHY interface mode.
*
* Optional method. When not provided, config->mac_capabilities will be used.
* When implemented, this returns the MAC capabilities for the specified
* interface mode where there is some special handling required by the MAC
* driver (e.g. not supporting half-duplex in certain interface modes.)
*/
unsigned long mac_get_caps(struct phylink_config *config,
phy_interface_t interface);
/** /**
* mac_select_pcs: Select a PCS for the interface mode. * mac_select_pcs: Select a PCS for the interface mode.
* @config: a pointer to a &struct phylink_config. * @config: a pointer to a &struct phylink_config.
......
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