Commit 11de5770 authored by David S. Miller's avatar David S. Miller

Merge branch 'Phylink-PCS-updates'

Russell King says:

====================
Phylink PCS updates

This series updates the rudimentary phylink PCS support with the
results of the last four months of development of that.  Phylink
PCS support was initially added back at the end of March, when it
became clear that the current approach of treating everything at
the MAC end as being part of the MAC was inadequate.

However, this rudimentary implementation was fine initially for
mvneta and similar, but in practice had a fair number of issues,
particularly when ethtool interfaces were used to change various
link properties.

It became apparent that relying on the phylink_config structure for
the PCS was also bad when it became clear that the same PCS was used
in DSA drivers as well as in NXPs other offerings, and there was a
desire to re-use that code.

It also became apparent that splitting the "configuration" step on
an interface mode configuration between the MAC and PCS using just
mac_config() and pcs_config() methods was not sufficient for some
setups, as the MAC needed to be "taken down" prior to making changes,
and once all settings were complete, the MAC could only then be
resumed.

This series addresses these points, progressing PCS support, and
has been developed with mvneta and DPAA2 setups, with work on both
those drivers to prove this approach.  It has been rigorously tested
with mvneta, as that provides the most flexibility for testing the
various code paths.

To solve the phylink_config reuse problem, we introduce a struct
phylink_pcs, which contains the minimal information necessary, and it
is intended that this is embedded in the PCS private data structure.

To solve the interface mode configuration problem, we introduce two
new MAC methods, mac_prepare() and mac_finish() which wrap the entire
interface mode configuration only.  This has the additional benefit of
relieving MAC drivers from working out whether an interface change has
occurred, and whether they need to do some major work.

I have not yet updated all the interface documentation for these
changes yet, that work remains, but this patch set is provided in the
hope that those working on PCS support in NXP will find this useful.

Since there is a lot of change here, this is the reason why I strongly
advise that everyone has converted to the mac_link_up() way of
configuring the link parameters when the link comes up, rather than
the old way of using mac_config() - especially as splitting the PCS
changes how and when phylink calls mac_config(). Although no change
for existing users is intended, that is something I no longer am able
to test.

Changes since RFC:
- fix bisect build failure
- add patch to use config.an_enabled
- rename phylink_config_interface to phylink_major_reconfig
- add expanded documentation for phylink_set_pcs()
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ccbc6dac 93eaceb0
This diff is collapsed.
......@@ -76,7 +76,9 @@ struct phylink_config {
* struct phylink_mac_ops - MAC operations structure.
* @validate: Validate and update the link configuration.
* @mac_pcs_get_state: Read the current link state from the hardware.
* @mac_prepare: prepare for a major reconfiguration of the interface.
* @mac_config: configure the MAC for the selected mode and state.
* @mac_finish: finish a major reconfiguration of the interface.
* @mac_an_restart: restart 802.3z BaseX autonegotiation.
* @mac_link_down: take the link down.
* @mac_link_up: allow the link to come up.
......@@ -89,8 +91,12 @@ struct phylink_mac_ops {
struct phylink_link_state *state);
void (*mac_pcs_get_state)(struct phylink_config *config,
struct phylink_link_state *state);
int (*mac_prepare)(struct phylink_config *config, unsigned int mode,
phy_interface_t iface);
void (*mac_config)(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state);
int (*mac_finish)(struct phylink_config *config, unsigned int mode,
phy_interface_t iface);
void (*mac_an_restart)(struct phylink_config *config);
void (*mac_link_down)(struct phylink_config *config, unsigned int mode,
phy_interface_t interface);
......@@ -145,6 +151,31 @@ void validate(struct phylink_config *config, unsigned long *supported,
void mac_pcs_get_state(struct phylink_config *config,
struct phylink_link_state *state);
/**
* mac_prepare() - prepare to change the PHY interface mode
* @config: a pointer to a &struct phylink_config.
* @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
* @iface: interface mode to switch to
*
* phylink will call this method at the beginning of a full initialisation
* of the link, which includes changing the interface mode or at initial
* startup time. It may be called for the current mode. The MAC driver
* should perform whatever actions are required, e.g. disabling the
* Serdes PHY.
*
* This will be the first call in the sequence:
* - mac_prepare()
* - mac_config()
* - pcs_config()
* - possible pcs_an_restart()
* - mac_finish()
*
* Returns zero on success, or negative errno on failure which will be
* reported to the kernel log.
*/
int mac_prepare(struct phylink_config *config, unsigned int mode,
phy_interface_t iface);
/**
* mac_config() - configure the MAC for the selected mode and state
* @config: a pointer to a &struct phylink_config.
......@@ -220,6 +251,23 @@ void mac_pcs_get_state(struct phylink_config *config,
void mac_config(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state);
/**
* mac_finish() - finish a to change the PHY interface mode
* @config: a pointer to a &struct phylink_config.
* @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
* @iface: interface mode to switch to
*
* phylink will call this if it called mac_prepare() to allow the MAC to
* complete any necessary steps after the MAC and PCS have been configured
* for the @mode and @iface. E.g. a MAC driver may wish to re-enable the
* Serdes PHY here if it was previously disabled by mac_prepare().
*
* Returns zero on success, or negative errno on failure which will be
* reported to the kernel log.
*/
int mac_finish(struct phylink_config *config, unsigned int mode,
phy_interface_t iface);
/**
* mac_an_restart() - restart 802.3z BaseX autonegotiation
* @config: a pointer to a &struct phylink_config.
......@@ -273,6 +321,21 @@ void mac_link_up(struct phylink_config *config, struct phy_device *phy,
int speed, int duplex, bool tx_pause, bool rx_pause);
#endif
struct phylink_pcs_ops;
/**
* struct phylink_pcs - PHYLINK PCS instance
* @ops: a pointer to the &struct phylink_pcs_ops structure
* @poll: poll the PCS for link changes
*
* This structure is designed to be embedded within the PCS private data,
* and will be passed between phylink and the PCS.
*/
struct phylink_pcs {
const struct phylink_pcs_ops *ops;
bool poll;
};
/**
* struct phylink_pcs_ops - MAC PCS operations structure.
* @pcs_get_state: read the current MAC PCS link state from the hardware.
......@@ -282,20 +345,21 @@ void mac_link_up(struct phylink_config *config, struct phy_device *phy,
* (where necessary).
*/
struct phylink_pcs_ops {
void (*pcs_get_state)(struct phylink_config *config,
void (*pcs_get_state)(struct phylink_pcs *pcs,
struct phylink_link_state *state);
int (*pcs_config)(struct phylink_config *config, unsigned int mode,
int (*pcs_config)(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface,
const unsigned long *advertising);
void (*pcs_an_restart)(struct phylink_config *config);
void (*pcs_link_up)(struct phylink_config *config, unsigned int mode,
const unsigned long *advertising,
bool permit_pause_to_mac);
void (*pcs_an_restart)(struct phylink_pcs *pcs);
void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface, int speed, int duplex);
};
#if 0 /* For kernel-doc purposes only. */
/**
* pcs_get_state() - Read the current inband link state from the hardware
* @config: a pointer to a &struct phylink_config.
* @pcs: a pointer to a &struct phylink_pcs.
* @state: a pointer to a &struct phylink_link_state.
*
* Read the current inband link state from the MAC PCS, reporting the
......@@ -308,18 +372,20 @@ struct phylink_pcs_ops {
* When present, this overrides mac_pcs_get_state() in &struct
* phylink_mac_ops.
*/
void pcs_get_state(struct phylink_config *config,
void pcs_get_state(struct phylink_pcs *pcs,
struct phylink_link_state *state);
/**
* pcs_config() - Configure the PCS mode and advertisement
* @config: a pointer to a &struct phylink_config.
* @pcs: a pointer to a &struct phylink_pcs.
* @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
* @interface: interface mode to be used
* @advertising: adertisement ethtool link mode mask
* @permit_pause_to_mac: permit forwarding pause resolution to MAC
*
* Configure the PCS for the operating mode, the interface mode, and set
* the advertisement mask.
* the advertisement mask. @permit_pause_to_mac indicates whether the
* hardware may forward the pause mode resolution to the MAC.
*
* When operating in %MLO_AN_INBAND, inband should always be enabled,
* otherwise inband should be disabled.
......@@ -331,21 +397,21 @@ void pcs_get_state(struct phylink_config *config,
*
* For most 10GBASE-R, there is no advertisement.
*/
int (*pcs_config)(struct phylink_config *config, unsigned int mode,
phy_interface_t interface, const unsigned long *advertising);
int pcs_config(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface, const unsigned long *advertising);
/**
* pcs_an_restart() - restart 802.3z BaseX autonegotiation
* @config: a pointer to a &struct phylink_config.
* @pcs: a pointer to a &struct phylink_pcs.
*
* When PCS ops are present, this overrides mac_an_restart() in &struct
* phylink_mac_ops.
*/
void (*pcs_an_restart)(struct phylink_config *config);
void pcs_an_restart(struct phylink_pcs *pcs);
/**
* pcs_link_up() - program the PCS for the resolved link configuration
* @config: a pointer to a &struct phylink_config.
* @pcs: a pointer to a &struct phylink_pcs.
* @mode: link autonegotiation mode
* @interface: link &typedef phy_interface_t mode
* @speed: link speed
......@@ -356,14 +422,14 @@ void (*pcs_an_restart)(struct phylink_config *config);
* mode without in-band AN needs to be manually configured for the link
* and duplex setting. Otherwise, this should be a no-op.
*/
void (*pcs_link_up)(struct phylink_config *config, unsigned int mode,
phy_interface_t interface, int speed, int duplex);
void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface, int speed, int duplex);
#endif
struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
phy_interface_t iface,
const struct phylink_mac_ops *mac_ops);
void phylink_add_pcs(struct phylink *, const struct phylink_pcs_ops *ops);
void phylink_set_pcs(struct phylink *, struct phylink_pcs *pcs);
void phylink_destroy(struct phylink *);
int phylink_connect_phy(struct phylink *, struct phy_device *);
......@@ -412,6 +478,9 @@ void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs,
phy_interface_t interface,
const unsigned long *advertising);
int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode,
phy_interface_t interface,
const unsigned long *advertising);
void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs);
void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
......
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