net: dsa: mv88e6xxx: convert to phylink pcs
Subsystems (6)
Russell King (Oracle)
maintainercover net: dsa: mv88e6xxx: convert to phylink pcs
Hi,
This series converts mv88e6xxx to use phylink pcs, which I believe is the last DSA driver that needs to be converted before we can declare the whole of DSA as non-phylink legacy.
Briefly:
Patches 1 and 2 introduce a new phylink_pcs_inband() helper to indicate whether inband AN should be used. Note that the first patch fixes a bug in the current c22 helper where the SGMII exchange with the PHY would be disabled when AN is turned off on the PHY copper side.
Patch 3 gets rid of phylink's internal pcs_ops member, preferring instead to always use the version in the phylink_pcs structure. Changing this pointer is now no longer supported.
Patch 4 makes PCS polling slightly cleaner, avoiding the poll being triggered while we're making changes to the configuration.
Patch 5 and 6 introduce several PCS methods that are fundamentally necessary for mv88e6xxx to work around various issues - for example, in some devices, the PCS must be powered down when the CMODE field in the port control register is changed. In other devices, there are workarounds that need to be performed.
Patch 7 adds unlocked mdiobus and mdiodev accessors to complement the locking versions that are already there - which are needed for some of the mv88e6xxx conversions.
Patch 8 prepares DSA as a whole, adding support for the phylink mac_prepare() and mac_finish() methods. These two methods are used to force the link down over a major reconfiguration event, which has been found by people to be necessary on mv88e6xxx devices. These haven't been required until now as everything has been done via the mac_config() callback - which won't be true once we switch to phylink_pcs.
Patch 9 implements patch 8 on this driver.
Patches 10 and 11 prepare mv88e6xxx for the conversion.
Patches 12 through to 14 convert each "serdes" to phylink_pcs.
Patch 15 cleans up after the conversion.
drivers/net/dsa/mv88e6xxx/Makefile | 3 + drivers/net/dsa/mv88e6xxx/chip.c | 480 ++++---------- drivers/net/dsa/mv88e6xxx/chip.h | 25 +- drivers/net/dsa/mv88e6xxx/pcs-6185.c | 158 +++++ drivers/net/dsa/mv88e6xxx/pcs-6352.c | 383 +++++++++++ drivers/net/dsa/mv88e6xxx/pcs-639x.c | 834 ++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/port.c | 30 - drivers/net/dsa/mv88e6xxx/serdes.c | 1164 ++-------------------------------- drivers/net/dsa/mv88e6xxx/serdes.h | 110 +--- drivers/net/phy/mdio_bus.c | 24 +- drivers/net/phy/phylink.c | 141 ++-- include/linux/mdio.h | 26 + include/linux/phylink.h | 44 ++ include/net/dsa.h | 6 + net/dsa/port.c | 32 + 15 files changed, 1826 insertions(+), 1634 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
PATCH 1/15 net: phylink: fix SGMII inband autoneg enable
When we are operating in SGMII inband mode, it implies that there is a PHY connected, and the ethtool advertisement for autoneg applies to the PHY, not the SGMII link. When in 1000base-X mode, then this applies to the 802.3z link and needs to be applied to the PCS.
Fix this.
--- drivers/net/phy/phylink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/phy/phylink.c +3 -1
@@ -3030,7 +3030,9 @@ int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode,/* Ensure ISOLATE bit is disabled */ if (mode ==MLO_AN_INBAND && -linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, advertising)) + (interface ==PHY_INTERFACE_MODE_SGMII || + interface ==PHY_INTERFACE_MODE_QSGMII || +linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, advertising))) bmcr =BMCR_ANENABLE ;else bmcr =0 ;
Signature · 1 line
2.30.2
Re: [PATCH net-next 01/15] net: phylink: fix SGMII inband autoneg enable
Quoted 9 lines · Russell King (Oracle)
When we are operating in SGMII inband mode, it implies that there is a PHY connected, and the ethtool advertisement for autoneg applies to the PHY, not the SGMII link. When in 1000base-X mode, then this applies to the 802.3z link and needs to be applied to the PCS.
Fix this.
Fixes 92817dad7dcb ("net: phylink: Support disabling autonegotiation for PCS")Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 2/15 net: phylink: add phylink_pcs_inband()
In reply to Russell King (Oracle)Add phylink_pcs_inband() to indicate whether the PCS should be using inband signalling.
--- drivers/net/phy/phylink.c | 5 +---- include/linux/phylink.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/net/phy/phylink.c +1 -4
@@ -3029,10 +3029,7 @@ int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode, }/* Ensure ISOLATE bit is disabled */ -if (mode ==MLO_AN_INBAND && - (interface ==PHY_INTERFACE_MODE_SGMII || - interface ==PHY_INTERFACE_MODE_QSGMII || -linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, advertising))) +if (phylink_pcs_inband (mode, interface, advertising)) bmcr =BMCR_ANENABLE ;else bmcr =0 ;
include/linux/phylink.h +22 -0
@@ -50,6 +50,28 @@ static inline bool phylink_autoneg_inband(unsigned int mode)return mode ==MLO_AN_INBAND ; } +/** +* phylink_pcs_inband() - helper to indicate whether to enable inband signalling +* @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. +* @interface: interface mode to be used +* @advertising: adertisement ethtool link mode mask +* +* Returns true if the mode/interface/advertising mask indicates that we +* should be using inband signalling at the PCS block, false otherwise. +*/ +static inline bool phylink_pcs_inband (unsigned int mode, +phy_interface_t interface, +const unsigned long *advertising) +{ +if (phylink_autoneg_inband (mode) && + (interface ==PHY_INTERFACE_MODE_SGMII || + interface ==PHY_INTERFACE_MODE_QSGMII || +linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, advertising))) +return true; +else +return false; +} +/** * struct phylink_link_state - link state structure * @advertising: ethtool bitmask containing advertised link modes
Signature · 1 line
2.30.2
Re: [PATCH net-next 02/15] net: phylink: add phylink_pcs_inband()
Quoted 4 lines · Russell King (Oracle)
Add
phylink_pcs_inband()to indicate whether the PCS should be using inband signalling.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Jakub Kicinski
maintainerRe: [PATCH net-next 02/15] net: phylink: add phylink_pcs_inband()
In reply to Russell King (Oracle)include/linux/phylink.h static inline bool phylink_autoneg_inband(unsigned int mode) · line 72
Quoted 7 lines · On Mon, 13 Jun 2022 14:00:31 +0100 Russell King (Oracle) wrote:
include/linux/phylink.h +7
-0+if (phylink_autoneg_inband (mode) && + (interface ==PHY_INTERFACE_MODE_SGMII || + interface ==PHY_INTERFACE_MODE_QSGMII || +linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, advertising))) +return true; +else +return false;
Okay, let me be a little annoying...
Could you run thru checkpatch --strict and fix the few whitespace issues it points out? There's a handful of spaces instead of tabs, unaligned continuation lines and an unnecessary bracket.
Patch 1 does not need to be backported so I presume it can lose the fixes tag?
The quoted code can be converted into a direct return of the condition, I don't really care but I think there are bots out there which will send a "fix" soon if we commit this.
And patch 10 generates a transient "function should be static" warning. I think you need a __maybe_unused on mv88e6xxx_pcs_select() as well.
Russell King (Oracle)
maintainerRe: [PATCH net-next 02/15] net: phylink: add phylink_pcs_inband()
Quoted 10 lines · Jakub Kicinski
include/linux/phylink.h static inline bool phylink_autoneg_inband(unsigned int mode) · line 72
Quoted 7 lines · On Mon, 13 Jun 2022 14:00:31 +0100 Russell King (Oracle) wrote:
include/linux/phylink.h +7
-0+if (phylink_autoneg_inband (mode) && + (interface ==PHY_INTERFACE_MODE_SGMII || + interface ==PHY_INTERFACE_MODE_QSGMII || +linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, advertising))) +return true; +else +return false;Okay, let me be a little annoying...
No, not annoying!
Quoted 3 lines
Could you run thru checkpatch --strict and fix the few whitespace issues it points out? There's a handful of spaces instead of tabs, unaligned continuation lines and an unnecessary bracket.
That somewhat surprises me... will fix most of the strict errors, except this one:
WARNING: function definition argument 'struct mv88e639x_pcs *' should also have an identifier name
#337: FILE: drivers/net/dsa/mv88e6xxx/pcs-639x.c:93:
+ irqreturn_t (*handler)(struct mv88e639x_pcs *);
because its utterly pointless. What extra information would adding "pcs" give to the reader? I can Understand it for standard C types because they are opaque, but not for this.
Quoted 2 lines
Patch 1 does not need to be backported so I presume it can lose the fixes tag?
As the commit talks about fixing something, in my experience the commit will get automatically selected for backporting to stable trees whether or not it has a fixes tag on it. The only way to stop that happening is not through avoiding a fixes tag, but to keep on top of the stable tree emails to stop patches being backported that don't need to be.
If you still want me to remove it, I will, but I predict it will still be backported.
Quoted 6 lines
The quoted code can be converted into a direct return of the condition, I don't really care but I think there are bots out there which will send a "fix" soon if we commit this.
And patch 10 generates a transient "function should be static" warning. I think you need a
__maybe_unusedonmv88e6xxx_pcs_select()as well.
Gah, I did build-test each patch individually, but I guess because of the time it takes to do so I must have not looked at the results properly - will fix.
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Jakub Kicinski
maintainerRe: [PATCH net-next 02/15] net: phylink: add phylink_pcs_inband()
Quoted 11 lines · On Wed, 15 Jun 2022 09:16:54 +0100 Russell King (Oracle) wrote:
Quoted 2 lines
Patch 1 does not need to be backported so I presume it can lose the fixes tag?
As the commit talks about fixing something, in my experience the commit will get automatically selected for backporting to stable trees whether or not it has a fixes tag on it. The only way to stop that happening is not through avoiding a fixes tag, but to keep on top of the stable tree emails to stop patches being backported that don't need to be.
If you still want me to remove it, I will, but I predict it will still be backported.
Fair, but the argument is not very... "clean", if you will. I read the argument as "the unwelcome thing is likely to happen anyway, so doesn't matter". But Fixes serves no purpose here, since we don't expect the backport. So we are defaulting to adding something useless on the basis of it not making things worse?
I'm only saying that to make sure I understand your perspective. Obviously not something I'd hold your patches over, fine either way.
Russell King (Oracle)
maintainerRe: [PATCH net-next 02/15] net: phylink: add phylink_pcs_inband()
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Wed, 15 Jun 2022 09:16:54 +0100 Russell King (Oracle) wrote:
Quoted 2 lines
Patch 1 does not need to be backported so I presume it can lose the fixes tag?
As the commit talks about fixing something, in my experience the commit will get automatically selected for backporting to stable trees whether or not it has a fixes tag on it. The only way to stop that happening is not through avoiding a fixes tag, but to keep on top of the stable tree emails to stop patches being backported that don't need to be.
Quoted 8 lines
Quoted 2 lines
If you still want me to remove it, I will, but I predict it will still be backported.
Fair, but the argument is not very... "clean", if you will. I read the argument as "the unwelcome thing is likely to happen anyway, so doesn't matter". But Fixes serves no purpose here, since we don't expect the backport. So we are defaulting to adding something useless on the basis of it not making things worse?
I think it's a point of view; I do absolutely expect the backport to happen irrespective of whether there's a Fixes there or not - which I base on all the patches that have been automatically selected seemingly just because the commit message talks about fixing something.
I am up for trying an experiment - I'll get rid of the Fixes: tag, and we'll see whether -stable picks the patch up anyway!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
PATCH 3/15 net: phylink: remove pcs_ops member
In reply to Russell King (Oracle)Remove the pcs_ops member from struct phylink, using the one stored in struct phylink_pcs instead.
--- drivers/net/phy/phylink.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/net/phy/phylink.c +19 -20
@@ -43,7 +43,6 @@ struct phylink {/* private: */ struct net_device *netdev;const struct phylink_mac_ops *mac_ops; -const struct phylink_pcs_ops *pcs_ops;struct phylink_config *config;struct phylink_pcs *pcs;struct device *dev;
@@ -779,8 +778,8 @@ static void phylink_mac_pcs_an_restart(struct phylink *pl)if (pl->link_config.an_enabled &&phy_interface_mode_is_8023z (pl->link_config.interface) &&phylink_autoneg_inband (pl->cur_link_an_mode)) { -if (pl->pcs_ops) - pl->pcs_ops->pcs_an_restart (pl->pcs); +if (pl->pcs) + pl->pcs->ops->pcs_an_restart (pl->pcs);else if (pl->config->legacy_pre_march2020) pl->mac_ops->mac_an_restart (pl->config); }
@@ -819,7 +818,6 @@ static void phylink_major_config(struct phylink *pl, bool restart,*/ if (pcs) { pl->pcs = pcs; - pl->pcs_ops = pcs->ops;if (!pl->phylink_disable_state && pl->cfg_link_an_mode ==MLO_AN_INBAND ) {
@@ -832,12 +830,12 @@ static void phylink_major_config(struct phylink *pl, bool restart,phylink_mac_config (pl, state); -if (pl->pcs_ops) { - err = pl->pcs_ops->pcs_config (pl->pcs, pl->cur_link_an_mode, - state->interface, - state->advertising, - !!(pl->link_config.pause & -MLO_PAUSE_AN )); +if (pl->pcs) { + err = pl->pcs->ops->pcs_config (pl->pcs, pl->cur_link_an_mode, + state->interface, + state->advertising, + !!(pl->link_config.pause & +MLO_PAUSE_AN ));if (err <0 )phylink_err (pl,"pcs_config failed: %pe\n" ,ERR_PTR (err));
@@ -869,7 +867,7 @@ static int phylink_change_inband_advert(struct phylink *pl)if (test_bit (PHYLINK_DISABLE_STOPPED , &pl->phylink_disable_state))return 0 ; -if (!pl->pcs_ops && pl->config->legacy_pre_march2020) { +if (!pl->pcs && pl->config->legacy_pre_march2020) {/* Legacy method */ phylink_mac_config (pl, &pl->link_config);phylink_mac_pcs_an_restart (pl);
@@ -886,10 +884,11 @@ static int phylink_change_inband_advert(struct phylink *pl)* restart negotiation if the pcs_config() helper indicates that * the programmed advertisement has changed. */ - ret = pl->pcs_ops->pcs_config (pl->pcs, pl->cur_link_an_mode, - pl->link_config.interface, - pl->link_config.advertising, - !!(pl->link_config.pause &MLO_PAUSE_AN )); + ret = pl->pcs->ops->pcs_config (pl->pcs, pl->cur_link_an_mode, + pl->link_config.interface, + pl->link_config.advertising, + !!(pl->link_config.pause & +MLO_PAUSE_AN ));if (ret <0 )return ret;
@@ -918,8 +917,8 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, state->an_complete =0 ; state->link =1 ; -if (pl->pcs_ops) - pl->pcs_ops->pcs_get_state (pl->pcs, state); +if (pl->pcs) + pl->pcs->ops->pcs_get_state (pl->pcs, state);else if (pl->mac_ops->mac_pcs_get_state && pl->config->legacy_pre_march2020) pl->mac_ops->mac_pcs_get_state (pl->config, state);
@@ -992,8 +991,8 @@ static void phylink_link_up(struct phylink *pl, pl->cur_interface = link_state.interface; -if (pl->pcs_ops && pl->pcs_ops->pcs_link_up) - pl->pcs_ops->pcs_link_up (pl->pcs, pl->cur_link_an_mode, +if (pl->pcs && pl->pcs->ops->pcs_link_up) + pl->pcs->ops->pcs_link_up (pl->pcs, pl->cur_link_an_mode, pl->cur_interface, link_state.speed, link_state.duplex);
@@ -1115,7 +1114,7 @@ static void phylink_resolve(struct work_struct *w) }phylink_major_config (pl, false, &link_state); pl->link_config.interface = link_state.interface; - }else if (!pl->pcs_ops && pl->config->legacy_pre_march2020) { + }else if (!pl->pcs && pl->config->legacy_pre_march2020) {/* The interface remains unchanged, only the speed, * duplex or pause settings have changed. Call the * old mac_config() method to configure the MAC/PCS
Signature · 1 line
2.30.2
Re: [PATCH net-next 03/15] net: phylink: remove pcs_ops member
Quoted 4 lines · Russell King (Oracle)
Remove the
pcs_opsmember from struct phylink, using the one stored in structphylink_pcsinstead.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 4/15 net: phylink: disable PCS polling over major configuration
In reply to Russell King (Oracle)While we are performing a major configuration, there is no point having the PCS polling timer running. Stop it before we begin preparing for the configuration change, and restart it only once we've successfully completed the change.
--- drivers/net/phy/phylink.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/net/phy/phylink.c +20 -9
@@ -758,6 +758,18 @@ static void phylink_resolve_flow(struct phylink_link_state *state) } } +static void phylink_pcs_poll_stop (struct phylink *pl) +{ +if (pl->cfg_link_an_mode ==MLO_AN_INBAND ) +del_timer (&pl->link_poll); +} + +static void phylink_pcs_poll_start (struct phylink *pl) +{ +if (pl->pcs->poll && pl->cfg_link_an_mode ==MLO_AN_INBAND ) +mod_timer (&pl->link_poll, jiffies +HZ ); +} +static void phylink_mac_config (struct phylink *pl,const struct phylink_link_state *state) {
@@ -789,6 +801,7 @@ static void phylink_major_config(struct phylink *pl, bool restart, const struct phylink_link_state *state) {struct phylink_pcs *pcs =NULL ; +bool pcs_changed = false;int err;phylink_dbg (pl,"major config %s\n" ,phy_modes (state->interface));
@@ -801,8 +814,12 @@ static void phylink_major_config(struct phylink *pl, bool restart, pcs);return ; } + + pcs_changed = pcs && pl->pcs != pcs; } +phylink_pcs_poll_stop (pl); +if (pl->mac_ops->mac_prepare) { err = pl->mac_ops->mac_prepare (pl->config, pl->cur_link_an_mode, state->interface);
@@ -816,16 +833,8 @@ static void phylink_major_config(struct phylink *pl, bool restart,/* If we have a new PCS, switch to the new PCS after preparing the MAC * for the change. */ -if (pcs) { +if (pcs_changed) { pl->pcs = pcs; - -if (!pl->phylink_disable_state && - pl->cfg_link_an_mode ==MLO_AN_INBAND ) { -if (pcs->poll) -mod_timer (&pl->link_poll, jiffies +HZ ); -else -del_timer (&pl->link_poll); - } }phylink_mac_config (pl, state);
@@ -852,6 +861,8 @@ static void phylink_major_config(struct phylink *pl, bool restart,phylink_err (pl,"mac_finish failed: %pe\n" ,ERR_PTR (err)); } + +phylink_pcs_poll_start (pl); }/*
Signature · 1 line
2.30.2
Re: [PATCH net-next 04/15] net: phylink: disable PCS polling over major configuration
Quoted 6 lines · Russell King (Oracle)
While we are performing a major configuration, there is no point having the PCS polling timer running. Stop it before we begin preparing for the configuration change, and restart it only once we've successfully completed the change.
Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 5/15 net: phylink: add pcs_enable()/pcs_disable() methods
In reply to Russell King (Oracle)Add phylink PCS enable/disable callbacks that will allow us to place IEEE 802.3 register compliant PCS in power-down mode while not being used.
--- drivers/net/phy/phylink.c | 48 +++++++++++++++++++++++++++++++-------- include/linux/phylink.h | 16 +++++++++++++ 2 files changed, 55 insertions(+), 9 deletions(-)
drivers/net/phy/phylink.c +39 -9
@@ -34,6 +34,10 @@ enum {PHYLINK_DISABLE_STOPPED ,PHYLINK_DISABLE_LINK ,PHYLINK_DISABLE_MAC_WOL , + +PCS_STATE_DOWN =0 , +PCS_STATE_STARTING , + PCS_STATE_STARTED, };/**
@@ -71,6 +75,7 @@ struct phylink {struct mutex state_mutex;struct phylink_link_state phy_state;struct work_struct resolve; +unsigned int pcs_state;bool mac_link_dropped;bool using_mac_select_pcs;
@@ -758,6 +763,22 @@ static void phylink_resolve_flow(struct phylink_link_state *state) } } +static void phylink_pcs_disable (struct phylink_pcs *pcs) +{ +if (pcs && pcs->ops->pcs_disable) + pcs->ops->pcs_disable (pcs); +} + +static int phylink_pcs_enable (struct phylink_pcs *pcs) +{ +int err =0 ; + +if (pcs && pcs->ops->pcs_enable) + err = pcs->ops->pcs_enable (pcs); + +return err; +} +static void phylink_pcs_poll_stop (struct phylink *pl) {if (pl->cfg_link_an_mode ==MLO_AN_INBAND )
@@ -766,7 +787,8 @@ static void phylink_pcs_poll_stop(struct phylink *pl)static void phylink_pcs_poll_start (struct phylink *pl) { -if (pl->pcs->poll && pl->cfg_link_an_mode ==MLO_AN_INBAND ) +if (pl->pcs && pl->pcs->poll && + pl->cfg_link_an_mode ==MLO_AN_INBAND )mod_timer (&pl->link_poll, jiffies +HZ ); }
@@ -834,11 +856,16 @@ static void phylink_major_config(struct phylink *pl, bool restart,* for the change. */ if (pcs_changed) { +phylink_pcs_disable (pl->pcs); + pl->pcs = pcs; }phylink_mac_config (pl, state); +if (pl->pcs_state ==PCS_STATE_STARTING || pcs_changed) +phylink_pcs_enable (pl->pcs); +if (pl->pcs) { err = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode, state->interface,
@@ -1273,6 +1300,7 @@ struct phylink *phylink_create(struct phylink_config *config, pl->link_config.speed =SPEED_UNKNOWN ; pl->link_config.duplex =DUPLEX_UNKNOWN ; pl->link_config.an_enabled = true; + pl->pcs_state =PCS_STATE_DOWN ; pl->mac_ops = mac_ops;__set_bit (PHYLINK_DISABLE_STOPPED , &pl->phylink_disable_state);timer_setup (&pl->link_poll, phylink_fixed_poll,0 );
@@ -1639,6 +1667,8 @@ void phylink_start(struct phylink *pl)if (pl->netdev)netif_carrier_off (pl->netdev); + pl->pcs_state =PCS_STATE_STARTING ; +/* Apply the link configuration to the MAC when starting. This allows * a fixed-link to start with the correct parameters, and also * ensures that we set the appropriate advertisement for Serdes links.
@@ -1649,6 +1679,8 @@ void phylink_start(struct phylink *pl)*/ phylink_mac_initial_config (pl, true); + pl->pcs_state =PCS_STATE_STARTED ; +phylink_enable_and_run_resolve (pl,PHYLINK_DISABLE_STOPPED );if (pl->cfg_link_an_mode ==MLO_AN_FIXED && pl->link_gpio) {
@@ -1667,15 +1699,9 @@ void phylink_start(struct phylink *pl) poll = true; } -switch (pl->cfg_link_an_mode) { -case MLO_AN_FIXED : +if (pl->cfg_link_an_mode ==MLO_AN_FIXED ) poll |= pl->config->poll_fixed_state; -break ; -case MLO_AN_INBAND : -if (pl->pcs) - poll |= pl->pcs->poll; -break ; - } +if (poll)mod_timer (&pl->link_poll, jiffies +HZ );if (pl->phydev)
@@ -1712,6 +1738,10 @@ void phylink_stop(struct phylink *pl) }phylink_run_resolve_and_disable (pl,PHYLINK_DISABLE_STOPPED ); + + pl->pcs_state =PCS_STATE_DOWN ; + +phylink_pcs_disable (pl->pcs); }EXPORT_SYMBOL_GPL (phylink_stop);
include/linux/phylink.h +16 -0
@@ -432,6 +432,8 @@ struct phylink_pcs {/** * struct phylink_pcs_ops - MAC PCS operations structure. * @pcs_validate: validate the link configuration. +* @pcs_enable: enable the PCS. +* @pcs_disable: disable the PCS. * @pcs_get_state: read the current MAC PCS link state from the hardware. * @pcs_config: configure the MAC PCS for the selected mode and state. * @pcs_an_restart: restart 802.3z BaseX autonegotiation.
@@ -441,6 +443,8 @@ struct phylink_pcs {struct phylink_pcs_ops {int (*pcs_validate)(struct phylink_pcs *pcs,unsigned long *supported,const struct phylink_link_state *state); +int (*pcs_enable)(struct phylink_pcs *pcs); +void (*pcs_disable)(struct phylink_pcs *pcs);void (*pcs_get_state)(struct phylink_pcs *pcs,struct phylink_link_state *state); int (*pcs_config)(struct phylink_pcs *pcs, unsigned int mode,
@@ -470,6 +474,18 @@ struct phylink_pcs_ops {int pcs_validate (struct phylink_pcs *pcs,unsigned long *supported,const struct phylink_link_state *state); +/** +* pcs_enable() - enable the PCS. +* @pcs: a pointer to a &struct phylink_pcs. +*/ +int pcs_enable (struct phylink_pcs *pcs); + +/** +* pcs_disable() - disable the PCS. +* @pcs: a pointer to a &struct phylink_pcs. +*/ +void pcs_disable (struct phylink_pcs *pcs); +/** * pcs_get_state() - Read the current inband link state from the hardware * @pcs: a pointer to a &struct phylink_pcs.
Signature · 1 line
2.30.2
PATCH 6/15 net: phylink: add pcs_pre_config()/pcs_post_config() methods
In reply to Russell King (Oracle)Add hooks that are called before and after the mac_config() call, which will be needed to deal with errata workarounds for the Marvell 88e639x DSA switches.
--- drivers/net/phy/phylink.c | 24 ++++++++++++++++++++++++ include/linux/phylink.h | 6 ++++++ 2 files changed, 30 insertions(+)
drivers/net/phy/phylink.c +24 -0
@@ -763,6 +763,24 @@ static void phylink_resolve_flow(struct phylink_link_state *state) } } +static void phylink_pcs_pre_config (struct phylink_pcs *pcs, +phy_interface_t interface) +{ +if (pcs && pcs->ops->pcs_pre_config) + pcs->ops->pcs_pre_config (pcs, interface); +} + +static int phylink_pcs_post_config (struct phylink_pcs *pcs, +phy_interface_t interface) +{ +int err =0 ; + +if (pcs && pcs->ops->pcs_post_config) + err = pcs->ops->pcs_post_config (pcs, interface); + +return err; +} +static void phylink_pcs_disable (struct phylink_pcs *pcs) {if (pcs && pcs->ops->pcs_disable)
@@ -861,8 +879,14 @@ static void phylink_major_config(struct phylink *pl, bool restart, pl->pcs = pcs; } +if (pl->pcs) +phylink_pcs_pre_config (pl->pcs, state->interface); +phylink_mac_config (pl, state); +if (pl->pcs) +phylink_pcs_post_config (pl->pcs, state->interface); +if (pl->pcs_state ==PCS_STATE_STARTING || pcs_changed)phylink_pcs_enable (pl->pcs);
include/linux/phylink.h +6 -0
@@ -434,6 +434,8 @@ struct phylink_pcs {* @pcs_validate: validate the link configuration. * @pcs_enable: enable the PCS. * @pcs_disable: disable the PCS. +* @pcs_pre_config: pre-mac_config method (for errata) +* @pcs_post_config: post-mac_config method (for arrata) * @pcs_get_state: read the current MAC PCS link state from the hardware. * @pcs_config: configure the MAC PCS for the selected mode and state. * @pcs_an_restart: restart 802.3z BaseX autonegotiation.
@@ -445,6 +447,10 @@ struct phylink_pcs_ops { const struct phylink_link_state *state);int (*pcs_enable)(struct phylink_pcs *pcs);void (*pcs_disable)(struct phylink_pcs *pcs); +void (*pcs_pre_config)(struct phylink_pcs *pcs, +phy_interface_t interface); +int (*pcs_post_config)(struct phylink_pcs *pcs, +phy_interface_t interface);void (*pcs_get_state)(struct phylink_pcs *pcs,struct phylink_link_state *state); int (*pcs_config)(struct phylink_pcs *pcs, unsigned int mode,
Signature · 1 line
2.30.2
Andrew Lunn
maintainerRe: [PATCH net-next 06/15] net: phylink: add pcs_pre_config()/pcs_post_config() methods
Quoted 5 lines · Russell King (Oracle)
Add hooks that are called before and after the
mac_config()call, which will be needed to deal with errata workarounds for the Marvell 88e639x DSA switches.Signed-off-by Russell King (Oracle) <[email protected]>
PATCH 7/15 net: mdio: add unlocked mdiobus and mdiodev bus accessors
In reply to Russell King (Oracle)Add the following unlocked accessors to complete the set:__mdiobus_modify()__mdiodev_read()__mdiodev_write()__mdiodev_modify()__mdiodev_modify_changed()
which we will need for Marvell DSA PCS conversion.
--- drivers/net/phy/mdio_bus.c | 24 ++++++++++++++++++++++-- include/linux/mdio.h | 26 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-)
drivers/net/phy/mdio_bus.c +22 -2
@@ -922,6 +922,26 @@ int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val) }EXPORT_SYMBOL (mdiobus_write); +/** +* __mdiobus_modify - Convenience function for modifying a given mdio device +* register +* @bus: the mii_bus struct +* @addr: the phy address +* @regnum: register number to write +* @mask: bit mask of bits to clear +* @set: bit mask of bits to set +*/ +int __mdiobus_modify (struct mii_bus *bus,int addr,u32 regnum,u16 mask, +u16 set) +{ +int err; + + err =__mdiobus_modify_changed (bus, addr, regnum, mask, set); + +return err <0 ? err :0 ; +} +EXPORT_SYMBOL_GPL (__mdiobus_modify); +/** * mdiobus_modify - Convenience function for modifying a given mdio device * register
@@ -936,10 +956,10 @@ int mdiobus_modify(struct mii_bus *bus, int addr, u32 regnum, u16 mask, u16 set)int err;mutex_lock (&bus->mdio_lock); - err =__mdiobus_modify_changed (bus, addr, regnum, mask, set); + err =__mdiobus_modify (bus, addr, regnum, mask, set);mutex_unlock (&bus->mdio_lock); -return err <0 ? err :0 ; +return err; }EXPORT_SYMBOL_GPL (mdiobus_modify);
include/linux/mdio.h +26 -0
@@ -414,6 +414,8 @@ static inline u32 linkmode_adv_to_mii_t1_adv_m_t(unsigned long *advertising)int __mdiobus_read (struct mii_bus *bus,int addr,u32 regnum);int __mdiobus_write (struct mii_bus *bus,int addr,u32 regnum,u16 val); +int __mdiobus_modify (struct mii_bus *bus,int addr,u32 regnum,u16 mask, +u16 set);int __mdiobus_modify_changed (struct mii_bus *bus,int addr,u32 regnum,u16 mask,u16 set);
@@ -426,6 +428,30 @@ int mdiobus_modify(struct mii_bus *bus, int addr, u32 regnum, u16 mask,int mdiobus_modify_changed (struct mii_bus *bus,int addr,u32 regnum,u16 mask,u16 set); +static inline int __mdiodev_read (struct mdio_device *mdiodev,u32 regnum) +{ +return __mdiobus_read (mdiodev->bus, mdiodev->addr, regnum); +} + +static inline int __mdiodev_write (struct mdio_device *mdiodev,u32 regnum, +u16 val) +{ +return __mdiobus_write (mdiodev->bus, mdiodev->addr, regnum, val); +} + +static inline int __mdiodev_modify (struct mdio_device *mdiodev,u32 regnum, +u16 mask,u16 set) +{ +return __mdiobus_modify (mdiodev->bus, mdiodev->addr, regnum, mask, set); +} + +static inline int __mdiodev_modify_changed (struct mdio_device *mdiodev, +u32 regnum,u16 mask,u16 set) +{ +return __mdiobus_modify_changed (mdiodev->bus, mdiodev->addr, regnum, + mask, set); +} +static inline int mdiodev_read (struct mdio_device *mdiodev,u32 regnum) {return mdiobus_read (mdiodev->bus, mdiodev->addr, regnum);
Signature · 1 line
2.30.2
Re: [PATCH net-next 07/15] net: mdio: add unlocked mdiobus and mdiodev bus accessors
Quoted 9 lines · Russell King (Oracle)
Add the following unlocked accessors to complete the set:
__mdiobus_modify()__mdiodev_read()__mdiodev_write()__mdiodev_modify()__mdiodev_modify_changed()
which we will need for Marvell DSA PCS conversion.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 8/15 net: dsa: add support for mac_prepare() and mac_finish() calls
In reply to Russell King (Oracle)Add DSA support for the phylink mac_prepare() and mac_finish() calls. These were introduced as part of the PCS support to allow MACs to perform preparatory steps prior to configuration, and finalisation steps after the MAC and PCS has been configured.
Introducing phylink_pcs support to the mv88e6xxx DSA driver needs some code moved out of its mac_config() stage into the mac_prepare() and mac_finish() stages, and this commit facilitates such code in DSA drivers.
--- include/net/dsa.h | 6 ++++++ net/dsa/port.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
include/net/dsa.h +6 -0
@@ -857,9 +857,15 @@ struct dsa_switch_ops { phy_interface_t iface);int (*phylink_mac_link_state)(struct dsa_switch *ds,int port,struct phylink_link_state *state); +int (*phylink_mac_prepare)(struct dsa_switch *ds,int port, +unsigned int mode, +phy_interface_t interface);void (*phylink_mac_config)(struct dsa_switch *ds,int port,unsigned int mode,const struct phylink_link_state *state); +int (*phylink_mac_finish)(struct dsa_switch *ds,int port, +unsigned int mode, +phy_interface_t interface);void (*phylink_mac_an_restart)(struct dsa_switch *ds,int port); void (*phylink_mac_link_down)(struct dsa_switch *ds, int port, unsigned int mode,
net/dsa/port.c +32 -0
@@ -1447,6 +1447,21 @@ dsa_port_phylink_mac_select_pcs(struct phylink_config *config,return pcs; } +static int dsa_port_phylink_mac_prepare (struct phylink_config *config, +unsigned int mode, +phy_interface_t interface) +{ + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); +struct dsa_switch *ds = dp->ds; +int err =0 ; + +if (ds->ops->phylink_mac_prepare) + err = ds->ops->phylink_mac_prepare (ds, dp->index, mode, + interface); + +return err; +} +static void dsa_port_phylink_mac_config (struct phylink_config *config,unsigned int mode,const struct phylink_link_state *state)
@@ -1460,6 +1475,21 @@ static void dsa_port_phylink_mac_config(struct phylink_config *config, ds->ops->phylink_mac_config (ds, dp->index, mode, state); } +static int dsa_port_phylink_mac_finish (struct phylink_config *config, +unsigned int mode, +phy_interface_t interface) +{ + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); +struct dsa_switch *ds = dp->ds; +int err =0 ; + +if (ds->ops->phylink_mac_finish) + err = ds->ops->phylink_mac_finish (ds, dp->index, mode, + interface); + +return err; +} +static void dsa_port_phylink_mac_an_restart (struct phylink_config *config) { struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
@@ -1515,7 +1545,9 @@ static const struct phylink_mac_ops dsa_port_phylink_mac_ops = { .validate = dsa_port_phylink_validate, .mac_select_pcs = dsa_port_phylink_mac_select_pcs, .mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state, + .mac_prepare = dsa_port_phylink_mac_prepare, .mac_config = dsa_port_phylink_mac_config, + .mac_finish = dsa_port_phylink_mac_finish, .mac_an_restart = dsa_port_phylink_mac_an_restart, .mac_link_down = dsa_port_phylink_mac_link_down, .mac_link_up = dsa_port_phylink_mac_link_up,
Signature · 1 line
2.30.2
Re: [PATCH net-next 08/15] net: dsa: add support for mac_prepare() and mac_finish() calls
Quoted 11 lines · Russell King (Oracle)
Add DSA support for the phylink
mac_prepare()andmac_finish()calls. These were introduced as part of the PCS support to allow MACs to perform preparatory steps prior to configuration, and finalisation steps after the MAC and PCS has been configured.Introducing
phylink_pcssupport to the mv88e6xxx DSA driver needs some code moved out of itsmac_config()stage into themac_prepare()andmac_finish()stages, and this commit facilitates such code in DSA drivers.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 9/15 net: dsa: mv88e6xxx: move link forcing to mac_prepare/mac_finish
In reply to Russell King (Oracle)Move the link forcing out of mac_config() and into the mac_prepare() and mac_finish() methods. This results in no change to the order in which these operations are performed, but does mean when we convert mv88e6xxx to phylink_pcs support, we will continue to preserve this ordering.
--- drivers/net/dsa/mv88e6xxx/chip.c | 65 ++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 20 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +45 -20
@@ -834,29 +834,38 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port, config->supported_interfaces); } +static int mv88e6xxx_mac_prepare (struct dsa_switch *ds,int port, +unsigned int mode,phy_interface_t interface) +{ +struct mv88e6xxx_chip *chip = ds->priv; +int err =0 ; + +/* In inband mode, the link may come up at any time while the link +* is not forced down. Force the link down while we reconfigure the +* interface mode. +*/ +if (mode ==MLO_AN_INBAND && + chip->ports[port].interface != interface && + chip->info->ops->port_set_link) { +mv88e6xxx_reg_lock (chip); + err = chip->info->ops->port_set_link (chip, port, +LINK_FORCED_DOWN ); +mv88e6xxx_reg_unlock (chip); + } + +return err; +} +static void mv88e6xxx_mac_config (struct dsa_switch *ds,int port,unsigned int mode,const struct phylink_link_state *state) {struct mv88e6xxx_chip *chip = ds->priv; -struct mv88e6xxx_port *p;int err =0 ; - p = &chip->ports[port]; -mv88e6xxx_reg_lock (chip);if (mode !=MLO_AN_PHY || !mv88e6xxx_phy_is_internal (ds, port)) { -/* In inband mode, the link may come up at any time while the -* link is not forced down. Force the link down while we -* reconfigure the interface mode. -*/ -if (mode ==MLO_AN_INBAND && - p->interface != state->interface && - chip->info->ops->port_set_link) - chip->info->ops->port_set_link (chip, port, -LINK_FORCED_DOWN ); - err =mv88e6xxx_port_config_interface (chip, port, state->interface);if (err && err != -EOPNOTSUPP )
@@ -873,24 +882,38 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, err =0 ; } +err_unlock: +mv88e6xxx_reg_unlock (chip); + +if (err && err != -EOPNOTSUPP ) +dev_err (ds->dev,"p%d: failed to configure MAC/PCS\n" , port); +} + +static int mv88e6xxx_mac_finish (struct dsa_switch *ds,int port, +unsigned int mode,phy_interface_t interface) +{ +struct mv88e6xxx_chip *chip = ds->priv; +int err =0 ; +/* Undo the forced down state above after completing configuration * irrespective of its state on entry, which allows the link to come * up in the in-band case where there is no separate SERDES. Also * ensure that the link can come up if the PPU is in use and we are * in PHY mode (we treat the PPU as an effective in-band mechanism.) */ +mv88e6xxx_reg_lock (chip); +if (chip->info->ops->port_set_link && - ((mode ==MLO_AN_INBAND && p->interface != state->interface) || + ((mode ==MLO_AN_INBAND && + chip->ports[port].interface != interface) || (mode ==MLO_AN_PHY &&mv88e6xxx_port_ppu_updates (chip, port)))) - chip->info->ops->port_set_link (chip, port,LINK_UNFORCED ); + err = chip->info->ops->port_set_link (chip, port,LINK_UNFORCED ); - p->interface = state->interface; - -err_unlock:mv88e6xxx_reg_unlock (chip); -if (err && err != -EOPNOTSUPP ) -dev_err (ds->dev,"p%d: failed to configure MAC/PCS\n" , port); + chip->ports[port].interface = interface; + +return err; } static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
@@ -6838,7 +6861,9 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .port_teardown = mv88e6xxx_port_teardown, .phylink_get_caps = mv88e6xxx_get_caps, .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, + .phylink_mac_prepare = mv88e6xxx_mac_prepare, .phylink_mac_config = mv88e6xxx_mac_config, + .phylink_mac_finish = mv88e6xxx_mac_finish, .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart, .phylink_mac_link_down = mv88e6xxx_mac_link_down, .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Signature · 1 line
2.30.2
Re: [PATCH net-next 09/15] net: dsa: mv88e6xxx: move link forcing to mac_prepare/mac_finish
Quoted 7 lines · Russell King (Oracle)
Move the link forcing out of
mac_config()and into themac_prepare()andmac_finish()methods. This results in no change to the order in which these operations are performed, but does mean when we convert mv88e6xxx tophylink_pcssupport, we will continue to preserve this ordering.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 10/15 net: dsa: mv88e6xxx: add infrastructure for phylink_pcs
In reply to Russell King (Oracle)Add infrastructure for phylink_pcs to the mv88e6xxx driver. This involves adding a mac_select_pcs() hook so we can pass the PCS to phylink at the appropriate time, and a PCS initialisation function.
As the various chip implementations are converted to use phylink_pcs, they are no longer reliant on the legacy phylink behaviour. We detect this by the use of this infrastructure, or the lack of any serdes.
--- drivers/net/dsa/mv88e6xxx/chip.c | 46 ++++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/chip.h | 6 +++++ 2 files changed, 52 insertions(+)
drivers/net/dsa/mv88e6xxx/chip.c +46 -0
@@ -832,6 +832,37 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port,if (mv88e6xxx_phy_is_internal (ds, port))__set_bit (PHY_INTERFACE_MODE_GMII , config->supported_interfaces); + +/* If we have a .pcs_init, or don't have a .serdes_pcs_get_state, +* serdes_pcs_config, serdes_pcs_an_restart, or serdes_pcs_link_up, +* we are not legacy. +*/ +if (chip->info->ops->pcs_init || + (!chip->info->ops->serdes_pcs_get_state && + !chip->info->ops->serdes_pcs_config && + !chip->info->ops->serdes_pcs_an_restart && + !chip->info->ops->serdes_pcs_link_up)) + config->legacy_pre_march2020 = false; +} + +static struct phylink_pcs *mv88e6xxx_pcs_select (struct mv88e6xxx_chip *chip, +int port, +phy_interface_t interface) +{ +return chip->ports[port].pcs_private; +} + +static struct phylink_pcs *__maybe_unused +mv88e6xxx_mac_select_pcs (struct dsa_switch *ds,int port, +phy_interface_t interface) +{ +struct mv88e6xxx_chip *chip = ds->priv; +struct phylink_pcs *pcs =NULL ; + +if (chip->info->ops->pcs_select) + pcs = chip->info->ops->pcs_select (chip, port, interface); + +return pcs; } static int mv88e6xxx_mac_prepare(struct dsa_switch *ds, int port,
@@ -3832,12 +3863,26 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)static int mv88e6xxx_port_setup (struct dsa_switch *ds,int port) { +struct mv88e6xxx_chip *chip = ds->priv; +int err; + +if (chip->info->ops->pcs_init) { + err = chip->info->ops->pcs_init (chip, port); +if (err) +return err; + } +return mv88e6xxx_setup_devlink_regions_port (ds, port); }static void mv88e6xxx_port_teardown (struct dsa_switch *ds,int port) { +struct mv88e6xxx_chip *chip = ds->priv; +mv88e6xxx_teardown_devlink_regions_port (ds, port); + +if (chip->info->ops->pcs_teardown) + chip->info->ops->pcs_teardown (chip, port); }/* prod_id for switch families which do not have a PHY model number */
@@ -6860,6 +6905,7 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .port_setup = mv88e6xxx_port_setup, .port_teardown = mv88e6xxx_port_teardown, .phylink_get_caps = mv88e6xxx_get_caps, + .phylink_mac_select_pcs = mv88e6xxx_mac_select_pcs, .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, .phylink_mac_prepare = mv88e6xxx_mac_prepare, .phylink_mac_config = mv88e6xxx_mac_config,
drivers/net/dsa/mv88e6xxx/chip.h +6 -0
@@ -280,6 +280,7 @@ struct mv88e6xxx_port {unsigned int serdes_irq;char serdes_irq_name[64 ];struct devlink_region *region; +void *pcs_private; };enum mv88e6xxx_region_id {
@@ -579,6 +580,11 @@ struct mv88e6xxx_ops {/* SERDES lane mapping */ int (*serdes_get_lane)(struct mv88e6xxx_chip *chip,int port); +int (*pcs_init)(struct mv88e6xxx_chip *chip,int port); +void (*pcs_teardown)(struct mv88e6xxx_chip *chip,int port); +struct phylink_pcs *(*pcs_select)(struct mv88e6xxx_chip *chip,int port, +phy_interface_t mode); +int (*serdes_pcs_get_state)(struct mv88e6xxx_chip *chip,int port,int lane,struct phylink_link_state *state); int (*serdes_pcs_config)(struct mv88e6xxx_chip *chip, int port,
Signature · 1 line
2.30.2
Re: [PATCH net-next 10/15] net: dsa: mv88e6xxx: add infrastructure for phylink_pcs
Quoted 9 lines · Russell King (Oracle)
Add infrastructure for
phylink_pcsto the mv88e6xxx driver. This involves adding amac_select_pcs()hook so we can pass the PCS to phylink at the appropriate time, and a PCS initialisation function.As the various chip implementations are converted to use
phylink_pcs, they are no longer reliant on the legacy phylink behaviour. We detect this by the use of this infrastructure, or the lack of any serdes.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 11/15 net: dsa: mv88e6xxx: export mv88e6xxx_pcs_decode_state()
In reply to Russell King (Oracle)Rename and export the PCS state decoding function so our PCS can make use of the functionality provided by this.
--- drivers/net/dsa/mv88e6xxx/serdes.c | 11 +++++------ drivers/net/dsa/mv88e6xxx/serdes.h | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-)
drivers/net/dsa/mv88e6xxx/serdes.c +5 -6
@@ -49,9 +49,8 @@ static int mv88e6390_serdes_write(struct mv88e6xxx_chip *chip,return mv88e6xxx_phy_write (chip, lane, reg_c45, val); } -static int mv88e6xxx_serdes_pcs_get_state (struct mv88e6xxx_chip *chip, -u16 bmsr,u16 lpa,u16 status, -struct phylink_link_state *state) +int mv88e6xxx_pcs_decode_state (struct device *dev,u16 bmsr,u16 lpa, +u16 status,struct phylink_link_state *state) { state->link = false;
@@ -92,7 +91,7 @@ static int mv88e6xxx_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, state->speed =SPEED_10 ;break ;default : -dev_err (chip->dev,"invalid PHY speed\n" ); +dev_err (dev,"invalid PHY speed\n" );return -EINVAL ; } } else if (state->link &&
@@ -215,7 +214,7 @@ int mv88e6352_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port,return err; } -return mv88e6xxx_serdes_pcs_get_state (chip, bmsr, lpa, status, state); +return mv88e6xxx_pcs_decode_state (chip->dev, bmsr, lpa, status, state); } int mv88e6352_serdes_pcs_an_restart(struct mv88e6xxx_chip *chip, int port,
@@ -945,7 +944,7 @@ static int mv88e6390_serdes_pcs_get_state_sgmii(struct mv88e6xxx_chip *chip,return err; } -return mv88e6xxx_serdes_pcs_get_state (chip, bmsr, lpa, status, state); +return mv88e6xxx_pcs_decode_state (chip->dev, bmsr, lpa, status, state); } static int mv88e6390_serdes_pcs_get_state_10g(struct mv88e6xxx_chip *chip,
drivers/net/dsa/mv88e6xxx/serdes.h +5 -0
@@ -12,6 +12,8 @@#include "chip.h" +struct phylink_link_state ; +#define MV88E6352_ADDR_SERDES 0x0f#define MV88E6352_SERDES_PAGE_FIBER 0x01#define MV88E6352_SERDES_IRQ 0x0b
@@ -103,6 +105,9 @@#define MV88E6393X_ERRATA_4_8_REG 0xF074#define MV88E6393X_ERRATA_4_8_BIT BIT(14) +int mv88e6xxx_pcs_decode_state (struct device *dev,u16 bmsr,u16 lpa, +u16 status,struct phylink_link_state *state); +int mv88e6185_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6341_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6352_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);
Signature · 1 line
2.30.2
Re: [PATCH net-next 11/15] net: dsa: mv88e6xxx: export mv88e6xxx_pcs_decode_state()
Quoted 4 lines · Russell King (Oracle)
Rename and export the PCS state decoding function so our PCS can make use of the functionality provided by this.
Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 12/15 net: dsa: mv88e6xxx: convert 88e6185 to phylink_pcs
In reply to Russell King (Oracle)Convert the 88E6185 SERDES code to use the phylink_pcs infrastructure.
--- drivers/net/dsa/mv88e6xxx/Makefile | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 17 +-- drivers/net/dsa/mv88e6xxx/pcs-6185.c | 158 +++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/serdes.c | 109 ------------------ drivers/net/dsa/mv88e6xxx/serdes.h | 11 +- 5 files changed, 167 insertions(+), 129 deletions(-) create mode 100644 drivers/net/dsa/mv88e6xxx/pcs-6185.c
drivers/net/dsa/mv88e6xxx/Makefile +1 -0
@@ -9,6 +9,7 @@ mv88e6xxx-objs += global2.o mv88e6xxx-objs += global2_avb.o mv88e6xxx-objs += global2_scratch.o mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += hwtstamp.o +mv88e6xxx-objs += pcs-6185.o mv88e6xxx-objs += phy.o mv88e6xxx-objs += port.o mv88e6xxx-objs += port_hidden.o
drivers/net/dsa/mv88e6xxx/chip.c +6 -11
@@ -4164,9 +4164,8 @@ static const struct mv88e6xxx_ops mv88e6095_ops = { .stats_get_strings = mv88e6095_stats_get_strings, .stats_get_stats = mv88e6095_stats_get_stats, .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, - .serdes_power = mv88e6185_serdes_power, - .serdes_get_lane = mv88e6185_serdes_get_lane, - .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, + .pcs_init = mv88e6185_pcs_init, + .pcs_select = mv88e6xxx_pcs_select, .ppu_enable = mv88e6185_g1_ppu_enable, .ppu_disable = mv88e6185_g1_ppu_disable, .reset = mv88e6185_g1_reset,
@@ -4208,12 +4207,9 @@ static const struct mv88e6xxx_ops mv88e6097_ops = { .set_egress_port = mv88e6095_g1_set_egress_port, .watchdog_ops = &mv88e6097_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, - .serdes_power = mv88e6185_serdes_power, - .serdes_get_lane = mv88e6185_serdes_get_lane, - .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, + .pcs_init = mv88e6185_pcs_init, + .pcs_select = mv88e6xxx_pcs_select, .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, - .serdes_irq_enable = mv88e6097_serdes_irq_enable, - .serdes_irq_status = mv88e6097_serdes_irq_status, .pot_clear = mv88e6xxx_g2_pot_clear, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6085_g1_rmu_disable,
@@ -4685,9 +4681,8 @@ static const struct mv88e6xxx_ops mv88e6185_ops = { .set_egress_port = mv88e6095_g1_set_egress_port, .watchdog_ops = &mv88e6097_watchdog_ops, .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, - .serdes_power = mv88e6185_serdes_power, - .serdes_get_lane = mv88e6185_serdes_get_lane, - .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, + .pcs_init = mv88e6185_pcs_init, + .pcs_select = mv88e6xxx_pcs_select, .set_cascade_port = mv88e6185_g1_set_cascade_port, .ppu_enable = mv88e6185_g1_ppu_enable, .ppu_disable = mv88e6185_g1_ppu_disable,
drivers/net/dsa/mv88e6xxx/pcs-6185.c new file +158 -0
158 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/serdes.c +0 -109
115 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/serdes.h +2 -9
@@ -108,7 +108,6 @@ struct phylink_link_state;int mv88e6xxx_pcs_decode_state (struct device *dev,u16 bmsr,u16 lpa,u16 status,struct phylink_link_state *state); -int mv88e6185_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6341_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6352_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6390_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);
@@ -122,8 +121,6 @@ int mv88e6390_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, int lane, unsigned int mode, phy_interface_t interface, const unsigned long *advertise); -int mv88e6185_serdes_pcs_get_state (struct mv88e6xxx_chip *chip,int port, -int lane,struct phylink_link_state *state);int mv88e6352_serdes_pcs_get_state (struct mv88e6xxx_chip *chip,int port,int lane,struct phylink_link_state *state); int mv88e6390_serdes_pcs_get_state(struct mv88e6xxx_chip *chip, int port,
@@ -142,8 +139,6 @@ unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip, int port);unsigned int mv88e6390_serdes_irq_mapping (struct mv88e6xxx_chip *chip,int port); -int mv88e6185_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane, -bool up);int mv88e6352_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane,bool on); int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
@@ -151,16 +146,12 @@ int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,int mv88e6393x_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane,bool on);int mv88e6393x_serdes_setup_errata (struct mv88e6xxx_chip *chip); -int mv88e6097_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane, -bool enable);int mv88e6352_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane,bool enable);int mv88e6390_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane,bool enable);int mv88e6393x_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane,bool enable); -irqreturn_t mv88e6097_serdes_irq_status (struct mv88e6xxx_chip *chip,int port, -int lane);irqreturn_t mv88e6352_serdes_irq_status (struct mv88e6xxx_chip *chip,int port,int lane); irqreturn_t mv88e6390_serdes_irq_status(struct mv88e6xxx_chip *chip, int port,
@@ -250,4 +241,6 @@ mv88e6xxx_serdes_irq_status(struct mv88e6xxx_chip *chip, int port, int lane) return chip->info->ops->serdes_irq_status(chip, port, lane); } +int mv88e6185_pcs_init (struct mv88e6xxx_chip *chip,int port); +#endif
Signature · 1 line
2.30.2
Re: [PATCH net-next 12/15] net: dsa: mv88e6xxx: convert 88e6185 to phylink_pcs
Quoted 3 lines · Russell King (Oracle)
Convert the 88E6185 SERDES code to use the
phylink_pcsinfrastructure.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 13/15 net: dsa: mv88e6xxx: convert 88e6352 to phylink_pcs
In reply to Russell King (Oracle)Convert the 88E6352 SERDES code to use the phylink_pcs infrastructure.
--- drivers/net/dsa/mv88e6xxx/Makefile | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 42 +-- drivers/net/dsa/mv88e6xxx/pcs-6352.c | 383 +++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/serdes.c | 222 ++-------------- drivers/net/dsa/mv88e6xxx/serdes.h | 21 +- 5 files changed, 423 insertions(+), 246 deletions(-) create mode 100644 drivers/net/dsa/mv88e6xxx/pcs-6352.c
drivers/net/dsa/mv88e6xxx/Makefile +1 -0
@@ -10,6 +10,7 @@ mv88e6xxx-objs += global2_avb.o mv88e6xxx-objs += global2_scratch.o mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += hwtstamp.o mv88e6xxx-objs += pcs-6185.o +mv88e6xxx-objs += pcs-6352.o mv88e6xxx-objs += phy.o mv88e6xxx-objs += port.o mv88e6xxx-objs += port_hidden.o
drivers/net/dsa/mv88e6xxx/chip.c +12 -30
69 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/pcs-6352.c new file +383 -0
383 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/serdes.c +23 -199
240 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/serdes.h +4 -17
@@ -105,55 +105,39 @@ struct phylink_link_state;#define MV88E6393X_ERRATA_4_8_REG 0xF074#define MV88E6393X_ERRATA_4_8_BIT BIT(14) +u16 mv88e6xxx_encode_forced_bmcr (int speed,int duplex);int mv88e6xxx_pcs_decode_state (struct device *dev,u16 bmsr,u16 lpa,u16 status,struct phylink_link_state *state);int mv88e6341_serdes_get_lane (struct mv88e6xxx_chip *chip,int port); -int mv88e6352_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6390_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6390x_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6393x_serdes_get_lane (struct mv88e6xxx_chip *chip,int port); -int mv88e6352_serdes_pcs_config (struct mv88e6xxx_chip *chip,int port, -int lane,unsigned int mode, -phy_interface_t interface, -const unsigned long *advertise);int mv88e6390_serdes_pcs_config (struct mv88e6xxx_chip *chip,int port,int lane,unsigned int mode,phy_interface_t interface,const unsigned long *advertise); -int mv88e6352_serdes_pcs_get_state (struct mv88e6xxx_chip *chip,int port, -int lane,struct phylink_link_state *state);int mv88e6390_serdes_pcs_get_state (struct mv88e6xxx_chip *chip,int port,int lane,struct phylink_link_state *state);int mv88e6393x_serdes_pcs_get_state (struct mv88e6xxx_chip *chip,int port,int lane,struct phylink_link_state *state); -int mv88e6352_serdes_pcs_an_restart (struct mv88e6xxx_chip *chip,int port, -int lane);int mv88e6390_serdes_pcs_an_restart (struct mv88e6xxx_chip *chip,int port,int lane); -int mv88e6352_serdes_pcs_link_up (struct mv88e6xxx_chip *chip,int port, -int lane,int speed,int duplex);int mv88e6390_serdes_pcs_link_up (struct mv88e6xxx_chip *chip,int port,int lane,int speed,int duplex);unsigned int mv88e6352_serdes_irq_mapping (struct mv88e6xxx_chip *chip,int port);unsigned int mv88e6390_serdes_irq_mapping (struct mv88e6xxx_chip *chip,int port); -int mv88e6352_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane, -bool on);int mv88e6390_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane,bool on);int mv88e6393x_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane,bool on);int mv88e6393x_serdes_setup_errata (struct mv88e6xxx_chip *chip); -int mv88e6352_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane, -bool enable);int mv88e6390_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane,bool enable);int mv88e6393x_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane,bool enable); -irqreturn_t mv88e6352_serdes_irq_status (struct mv88e6xxx_chip *chip,int port, -int lane);irqreturn_t mv88e6390_serdes_irq_status (struct mv88e6xxx_chip *chip,int port,int lane); irqreturn_t mv88e6393x_serdes_irq_status(struct mv88e6xxx_chip *chip, int port,
@@ -243,4 +227,7 @@ mv88e6xxx_serdes_irq_status(struct mv88e6xxx_chip *chip, int port, int lane)int mv88e6185_pcs_init (struct mv88e6xxx_chip *chip,int port); +int mv88e6352_pcs_init (struct mv88e6xxx_chip *chip,int port); +void mv88e6352_pcs_teardown (struct mv88e6xxx_chip *chip,int port); +#endif
Signature · 1 line
2.30.2
Re: [PATCH net-next 13/15] net: dsa: mv88e6xxx: convert 88e6352 to phylink_pcs
Quoted 3 lines · Russell King
Convert the 88E6352 SERDES code to use the
phylink_pcsinfrastructure.Signed-off-by Russell King <[email protected]>
Andrew
PATCH 14/15 net: dsa: mv88e6xxx: convert 88e639x to phylink_pcs
In reply to Russell King (Oracle)Convert the 88E6390, 88E6390X, and 88E6393X family of switches to use the phylink_pcs infrastructure.
--- drivers/net/dsa/mv88e6xxx/Makefile | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 98 +--- drivers/net/dsa/mv88e6xxx/pcs-639x.c | 834 +++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/serdes.c | 752 +----------------------- drivers/net/dsa/mv88e6xxx/serdes.h | 36 +- 5 files changed, 874 insertions(+), 847 deletions(-) create mode 100644 drivers/net/dsa/mv88e6xxx/pcs-639x.c
drivers/net/dsa/mv88e6xxx/Makefile +1 -0
@@ -11,6 +11,7 @@ mv88e6xxx-objs += global2_scratch.o mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += hwtstamp.o mv88e6xxx-objs += pcs-6185.o mv88e6xxx-objs += pcs-6352.o +mv88e6xxx-objs += pcs-639x.o mv88e6xxx-objs += phy.o mv88e6xxx-objs += port.o mv88e6xxx-objs += port_hidden.o
drivers/net/dsa/mv88e6xxx/chip.c +27 -71
176 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/pcs-639x.c new file +834 -0
834 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/serdes.c +1 -751
778 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/serdes.h +11 -25
@@ -46,6 +46,10 @@ struct phylink_link_state;/* 10GBASE-R and 10GBASE-X4/X2 */ #define MV88E6390_10G_CTRL1 (0x1000 + MDIO_CTRL1)#define MV88E6390_10G_STAT1 (0x1000 + MDIO_STAT1) +#define MV88E6390_10G_INT_ENABLE 0x9001 +#define MV88E6390_10G_INT_LINK_DOWN BIT(3) +#define MV88E6390_10G_INT_LINK_UP BIT(2) +#define MV88E6390_10G_INT_STATUS 0x9003#define MV88E6393X_10G_INT_ENABLE 0x9000#define MV88E6393X_10G_INT_LINK_CHANGE BIT(2)#define MV88E6393X_10G_INT_STATUS 0x9001
@@ -113,35 +117,10 @@ int mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);int mv88e6390_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6390x_serdes_get_lane (struct mv88e6xxx_chip *chip,int port);int mv88e6393x_serdes_get_lane (struct mv88e6xxx_chip *chip,int port); -int mv88e6390_serdes_pcs_config (struct mv88e6xxx_chip *chip,int port, -int lane,unsigned int mode, -phy_interface_t interface, -const unsigned long *advertise); -int mv88e6390_serdes_pcs_get_state (struct mv88e6xxx_chip *chip,int port, -int lane,struct phylink_link_state *state); -int mv88e6393x_serdes_pcs_get_state (struct mv88e6xxx_chip *chip,int port, -int lane,struct phylink_link_state *state); -int mv88e6390_serdes_pcs_an_restart (struct mv88e6xxx_chip *chip,int port, -int lane); -int mv88e6390_serdes_pcs_link_up (struct mv88e6xxx_chip *chip,int port, -int lane,int speed,int duplex);unsigned int mv88e6352_serdes_irq_mapping (struct mv88e6xxx_chip *chip,int port);unsigned int mv88e6390_serdes_irq_mapping (struct mv88e6xxx_chip *chip,int port); -int mv88e6390_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane, -bool on); -int mv88e6393x_serdes_power (struct mv88e6xxx_chip *chip,int port,int lane, -bool on); -int mv88e6393x_serdes_setup_errata (struct mv88e6xxx_chip *chip); -int mv88e6390_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port,int lane, -bool enable); -int mv88e6393x_serdes_irq_enable (struct mv88e6xxx_chip *chip,int port, -int lane,bool enable); -irqreturn_t mv88e6390_serdes_irq_status (struct mv88e6xxx_chip *chip,int port, -int lane); -irqreturn_t mv88e6393x_serdes_irq_status (struct mv88e6xxx_chip *chip,int port, -int lane);int mv88e6352_serdes_get_sset_count (struct mv88e6xxx_chip *chip,int port);int mv88e6352_serdes_get_strings (struct mv88e6xxx_chip *chip,int port,uint8_t *data);
@@ -230,4 +209,11 @@ int mv88e6185_pcs_init(struct mv88e6xxx_chip *chip, int port);int mv88e6352_pcs_init (struct mv88e6xxx_chip *chip,int port);void mv88e6352_pcs_teardown (struct mv88e6xxx_chip *chip,int port); +int mv88e6390_pcs_init (struct mv88e6xxx_chip *chip,int port); +int mv88e6393x_pcs_init (struct mv88e6xxx_chip *chip,int port); +void mv88e639x_pcs_teardown (struct mv88e6xxx_chip *chip,int port); + +struct phylink_pcs *mv88e639x_pcs_select (struct mv88e6xxx_chip *chip,int port, +phy_interface_t mode); +#endif
Signature · 1 line
2.30.2
Re: [PATCH net-next 14/15] net: dsa: mv88e6xxx: convert 88e639x to phylink_pcs
Quoted 4 lines · Russell King (Oracle)
Convert the 88E6390, 88E6390X, and 88E6393X family of switches to use the
phylink_pcsinfrastructure.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
PATCH 15/15 net: dsa: mv88e6xxx: cleanup after phylink_pcs conversion
In reply to Russell King (Oracle)Now that mv88e6xxx is completely converted to using phylink_pcs support, we have no need for the serdes methods. Remove all this infrastructure. Also remove the __maybe_unused from mv88e6xxx_pcs_select()
--- drivers/net/dsa/mv88e6xxx/chip.c | 236 +---------------------------- drivers/net/dsa/mv88e6xxx/chip.h | 21 --- drivers/net/dsa/mv88e6xxx/port.c | 30 ---- drivers/net/dsa/mv88e6xxx/serdes.h | 45 ------ 4 files changed, 5 insertions(+), 327 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +5 -231
@@ -495,81 +495,6 @@ static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)return !!(reg &MV88E6XXX_PORT_STS_PHY_DETECT ); } -static int mv88e6xxx_serdes_pcs_get_state (struct dsa_switch *ds,int port, -struct phylink_link_state *state) -{ -struct mv88e6xxx_chip *chip = ds->priv; -int lane; -int err; - -mv88e6xxx_reg_lock (chip); - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane >=0 && chip->info->ops->serdes_pcs_get_state) - err = chip->info->ops->serdes_pcs_get_state (chip, port, lane, - state); -else - err = -EOPNOTSUPP ; -mv88e6xxx_reg_unlock (chip); - -return err; -} - -static int mv88e6xxx_serdes_pcs_config (struct mv88e6xxx_chip *chip,int port, -unsigned int mode, -phy_interface_t interface, -const unsigned long *advertise) -{ -const struct mv88e6xxx_ops *ops = chip->info->ops; -int lane; - -if (ops->serdes_pcs_config) { - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane >=0 ) -return ops->serdes_pcs_config (chip, port, lane, mode, - interface, advertise); - } - -return 0 ; -} - -static void mv88e6xxx_serdes_pcs_an_restart (struct dsa_switch *ds,int port) -{ -struct mv88e6xxx_chip *chip = ds->priv; -const struct mv88e6xxx_ops *ops; -int err =0 ; -int lane; - - ops = chip->info->ops; - -if (ops->serdes_pcs_an_restart) { -mv88e6xxx_reg_lock (chip); - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane >=0 ) - err = ops->serdes_pcs_an_restart (chip, port, lane); -mv88e6xxx_reg_unlock (chip); - -if (err) -dev_err (ds->dev,"p%d: failed to restart AN\n" , port); - } -} - -static int mv88e6xxx_serdes_pcs_link_up (struct mv88e6xxx_chip *chip,int port, -unsigned int mode, -int speed,int duplex) -{ -const struct mv88e6xxx_ops *ops = chip->info->ops; -int lane; - -if (!phylink_autoneg_inband (mode) && ops->serdes_pcs_link_up) { - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane >=0 ) -return ops->serdes_pcs_link_up (chip, port, lane, - speed, duplex); - } - -return 0 ; -} -static const u8 mv88e6185_phy_interface_modes[] = { [MV88E6185_PORT_STS_CMODE_GMII_FD ] =PHY_INTERFACE_MODE_GMII , [MV88E6185_PORT_STS_CMODE_MII_100_FD_PS ] =PHY_INTERFACE_MODE_MII ,
@@ -833,15 +758,8 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port,__set_bit (PHY_INTERFACE_MODE_GMII , config->supported_interfaces); -/* If we have a .pcs_init, or don't have a .serdes_pcs_get_state, -* serdes_pcs_config, serdes_pcs_an_restart, or serdes_pcs_link_up, -* we are not legacy. -*/ -if (chip->info->ops->pcs_init || - (!chip->info->ops->serdes_pcs_get_state && - !chip->info->ops->serdes_pcs_config && - !chip->info->ops->serdes_pcs_an_restart && - !chip->info->ops->serdes_pcs_link_up)) +/* If we have a .pcs_init, we are not legacy. */ +if (chip->info->ops->pcs_init) config->legacy_pre_march2020 = false; }
@@ -852,9 +770,9 @@ static struct phylink_pcs *mv88e6xxx_pcs_select(struct mv88e6xxx_chip *chip,return chip->ports[port].pcs_private; } -static struct phylink_pcs *__maybe_unused -mv88e6xxx_mac_select_pcs (struct dsa_switch *ds,int port, -phy_interface_t interface) +static struct phylink_pcs *mv88e6xxx_mac_select_pcs (struct dsa_switch *ds, +int port, +phy_interface_t interface) {struct mv88e6xxx_chip *chip = ds->priv;struct phylink_pcs *pcs =NULL ;
@@ -901,16 +819,6 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, state->interface);if (err && err != -EOPNOTSUPP ) goto err_unlock; - - err =mv88e6xxx_serdes_pcs_config (chip, port, mode, - state->interface, - state->advertising); -/* FIXME: we should restart negotiation if something changed - -* which is something we get if we convert to using phylinks -* PCS operations. -*/ -if (err >0 ) - err =0 ; } err_unlock:
@@ -994,17 +902,6 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,*/ if (!mv88e6xxx_port_ppu_updates (chip, port) || mode ==MLO_AN_FIXED ) { -/* FIXME: for an automedia port, should we force the link -* down here - what if the link comes up due to "other" media -* while we're bringing the port up, how is the exclusivity -* handled in the Marvell hardware? E.g. port 2 on 88E6390 -* shared between internal PHY and Serdes. -*/ - err =mv88e6xxx_serdes_pcs_link_up (chip, port, mode, speed, - duplex); -if (err) - goto error; -if (ops->port_set_speed_duplex) { err = ops->port_set_speed_duplex (chip, port, speed, duplex);
@@ -3175,102 +3072,6 @@ static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)return 0 ; } -static irqreturn_t mv88e6xxx_serdes_irq_thread_fn (int irq,void *dev_id) -{ -struct mv88e6xxx_port *mvp = dev_id; -struct mv88e6xxx_chip *chip = mvp->chip; -irqreturn_t ret =IRQ_NONE ; -int port = mvp->port; -int lane; - -mv88e6xxx_reg_lock (chip); - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane >=0 ) - ret =mv88e6xxx_serdes_irq_status (chip, port, lane); -mv88e6xxx_reg_unlock (chip); - -return ret; -} - -static int mv88e6xxx_serdes_irq_request (struct mv88e6xxx_chip *chip,int port, -int lane) -{ -struct mv88e6xxx_port *dev_id = &chip->ports[port]; -unsigned int irq; -int err; - -/* Nothing to request if this SERDES port has no IRQ */ - irq =mv88e6xxx_serdes_irq_mapping (chip, port); -if (!irq) -return 0 ; - -snprintf (dev_id->serdes_irq_name,sizeof (dev_id->serdes_irq_name), -"mv88e6xxx-%s-serdes-%d" ,dev_name (chip->dev), port); - -/* Requesting the IRQ will trigger IRQ callbacks, so release the lock */ -mv88e6xxx_reg_unlock (chip); - err =request_threaded_irq (irq,NULL , mv88e6xxx_serdes_irq_thread_fn, -IRQF_ONESHOT , dev_id->serdes_irq_name, - dev_id); -mv88e6xxx_reg_lock (chip); -if (err) -return err; - - dev_id->serdes_irq = irq; - -return mv88e6xxx_serdes_irq_enable (chip, port, lane); -} - -static int mv88e6xxx_serdes_irq_free (struct mv88e6xxx_chip *chip,int port, -int lane) -{ -struct mv88e6xxx_port *dev_id = &chip->ports[port]; -unsigned int irq = dev_id->serdes_irq; -int err; - -/* Nothing to free if no IRQ has been requested */ -if (!irq) -return 0 ; - - err =mv88e6xxx_serdes_irq_disable (chip, port, lane); - -/* Freeing the IRQ will trigger IRQ callbacks, so release the lock */ -mv88e6xxx_reg_unlock (chip); -free_irq (irq, dev_id); -mv88e6xxx_reg_lock (chip); - - dev_id->serdes_irq =0 ; - -return err; -} - -static int mv88e6xxx_serdes_power (struct mv88e6xxx_chip *chip,int port, -bool on) -{ -int lane; -int err; - - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane <0 ) -return 0 ; - -if (on) { - err =mv88e6xxx_serdes_power_up (chip, port, lane); -if (err) -return err; - - err =mv88e6xxx_serdes_irq_request (chip, port, lane); - }else { - err =mv88e6xxx_serdes_irq_free (chip, port, lane); -if (err) -return err; - - err =mv88e6xxx_serdes_power_down (chip, port, lane); - } - -return err; -} -static int mv88e6xxx_set_egress_port (struct mv88e6xxx_chip *chip,enum mv88e6xxx_egress_direction direction,int port)
@@ -3593,29 +3394,6 @@ static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)return ret; } -static int mv88e6xxx_port_enable (struct dsa_switch *ds,int port, -struct phy_device *phydev) -{ -struct mv88e6xxx_chip *chip = ds->priv; -int err; - -mv88e6xxx_reg_lock (chip); - err =mv88e6xxx_serdes_power (chip, port, true); -mv88e6xxx_reg_unlock (chip); - -return err; -} - -static void mv88e6xxx_port_disable (struct dsa_switch *ds,int port) -{ -struct mv88e6xxx_chip *chip = ds->priv; - -mv88e6xxx_reg_lock (chip); -if (mv88e6xxx_serdes_power (chip, port, false)) -dev_err (chip->dev,"failed to power off SERDES\n" ); -mv88e6xxx_reg_unlock (chip); -} -static int mv88e6xxx_set_ageing_time (struct dsa_switch *ds,unsigned int ageing_time) {
@@ -6839,18 +6617,14 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .port_teardown = mv88e6xxx_port_teardown, .phylink_get_caps = mv88e6xxx_get_caps, .phylink_mac_select_pcs = mv88e6xxx_mac_select_pcs, - .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, .phylink_mac_prepare = mv88e6xxx_mac_prepare, .phylink_mac_config = mv88e6xxx_mac_config, .phylink_mac_finish = mv88e6xxx_mac_finish, - .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart, .phylink_mac_link_down = mv88e6xxx_mac_link_down, .phylink_mac_link_up = mv88e6xxx_mac_link_up, .get_strings = mv88e6xxx_get_strings, .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, .get_sset_count = mv88e6xxx_get_sset_count, - .port_enable = mv88e6xxx_port_enable, - .port_disable = mv88e6xxx_port_disable, .port_max_mtu = mv88e6xxx_get_max_mtu, .port_change_mtu = mv88e6xxx_change_mtu, .get_mac_eee = mv88e6xxx_get_mac_eee,
drivers/net/dsa/mv88e6xxx/chip.h +0 -21
@@ -277,8 +277,6 @@ struct mv88e6xxx_port {u8 cmode;bool mirror_ingress;bool mirror_egress; -unsigned int serdes_irq; -char serdes_irq_name[64 ];struct devlink_region *region;void *pcs_private; };
@@ -573,10 +571,6 @@ struct mv88e6xxx_ops {int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip); -/* Power on/off a SERDES interface */ -int (*serdes_power)(struct mv88e6xxx_chip *chip,int port,int lane, -bool up); -/* SERDES lane mapping */ int (*serdes_get_lane)(struct mv88e6xxx_chip *chip,int port);
@@ -585,24 +579,9 @@ struct mv88e6xxx_ops {struct phylink_pcs *(*pcs_select)(struct mv88e6xxx_chip *chip,int port,phy_interface_t mode); -int (*serdes_pcs_get_state)(struct mv88e6xxx_chip *chip,int port, -int lane,struct phylink_link_state *state); -int (*serdes_pcs_config)(struct mv88e6xxx_chip *chip,int port, -int lane,unsigned int mode, -phy_interface_t interface, -const unsigned long *advertise); -int (*serdes_pcs_an_restart)(struct mv88e6xxx_chip *chip,int port, -int lane); -int (*serdes_pcs_link_up)(struct mv88e6xxx_chip *chip,int port, -int lane,int speed,int duplex); -/* SERDES interrupt handling */ unsigned int (*serdes_irq_mapping)(struct mv88e6xxx_chip *chip,int port); -int (*serdes_irq_enable)(struct mv88e6xxx_chip *chip,int port,int lane, -bool enable); -irqreturn_t (*serdes_irq_status)(struct mv88e6xxx_chip *chip,int port, -int lane);/* Statistics from the SERDES interface */ int (*serdes_get_sset_count)(struct mv88e6xxx_chip *chip,int port);
drivers/net/dsa/mv88e6xxx/port.c +0 -30
@@ -539,7 +539,6 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port, phy_interface_t mode, bool force) {u16 cmode; -int lane;u16 reg;int err;
@@ -583,19 +582,6 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,if (cmode == chip->ports[port].cmode && !force)return 0 ; - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane >=0 ) { -if (chip->ports[port].serdes_irq) { - err =mv88e6xxx_serdes_irq_disable (chip, port, lane); -if (err) -return err; - } - - err =mv88e6xxx_serdes_power_down (chip, port, lane); -if (err) -return err; - } - chip->ports[port].cmode =0 ;if (cmode) {
@@ -611,22 +597,6 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,return err; chip->ports[port].cmode = cmode; - - lane =mv88e6xxx_serdes_get_lane (chip, port); -if (lane == -ENODEV ) -return 0 ; -if (lane <0 ) -return lane; - - err =mv88e6xxx_serdes_power_up (chip, port, lane); -if (err) -return err; - -if (chip->ports[port].serdes_irq) { - err =mv88e6xxx_serdes_irq_enable (chip, port, lane); -if (err) -return err; - } }return 0 ;
drivers/net/dsa/mv88e6xxx/serdes.h +0 -45
57 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH net-next 15/15] net: dsa: mv88e6xxx: cleanup after phylink_pcs conversion
Quoted 6 lines · Russell King (Oracle)
Now that mv88e6xxx is completely converted to using
phylink_pcssupport, we have no need for the serdes methods. Remove all this infrastructure. Also remove the__maybe_unusedfrommv88e6xxx_pcs_select()Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Quoted 45 lines · On Mon, 13 Jun 2022 13:59:03 +0100 "Russell King (Oracle)"…
Hi,
This series converts mv88e6xxx to use phylink pcs, which I believe is the last DSA driver that needs to be converted before we can declare the whole of DSA as non-phylink legacy.
Briefly:
Patches 1 and 2 introduce a newphylink_pcs_inband()helper to indicate whether inband AN should be used. Note that the first patch fixes a bug in the current c22 helper where the SGMII exchange with the PHY would be disabled when AN is turned off on the PHY copper side.Patch 3 gets rid of phylink's internal
pcs_opsmember, preferring instead to always use the version in thephylink_pcsstructure. Changing this pointer is now no longer supported.Patch 4 makes PCS polling slightly cleaner, avoiding the poll being triggered while we're making changes to the configuration.
Patch 5 and 6 introduce several PCS methods that are fundamentally necessary for mv88e6xxx to work around various issues - for example, in some devices, the PCS must be powered down when the CMODE field in the port control register is changed. In other devices, there are workarounds that need to be performed.
Patch 7 adds unlocked mdiobus and mdiodev accessors to complement the locking versions that are already there - which are needed for some of the mv88e6xxx conversions.
Patch 8 prepares DSA as a whole, adding support for the phylink
mac_prepare()andmac_finish()methods. These two methods are used to force the link down over a major reconfiguration event, which has been found by people to be necessary on mv88e6xxx devices. These haven't been required until now as everything has been done via themac_config()callback - which won't be true once we switch tophylink_pcs.Patch 9 implements patch 8 on this driver.
Patches 10 and 11 prepare mv88e6xxx for the conversion.
Patches 12 through to 14 convert each "serdes" to
phylink_pcs.Patch 15 cleans up after the conversion.
Quoted 17 lines
drivers/net/dsa/mv88e6xxx/Makefile | 3 + drivers/net/dsa/mv88e6xxx/chip.c | 480 ++++---------- drivers/net/dsa/mv88e6xxx/chip.h | 25 +- drivers/net/dsa/mv88e6xxx/pcs-6185.c | 158 +++++ drivers/net/dsa/mv88e6xxx/pcs-6352.c | 383 +++++++++++ drivers/net/dsa/mv88e6xxx/pcs-639x.c | 834 ++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/port.c | 30 - drivers/net/dsa/mv88e6xxx/serdes.c | 1164 ++-------------------------------- drivers/net/dsa/mv88e6xxx/serdes.h | 110 +--- drivers/net/phy/mdio_bus.c | 24 +- drivers/net/phy/phylink.c | 141 ++-- include/linux/mdio.h | 26 + include/linux/phylink.h | 44 ++ include/net/dsa.h | 6 + net/dsa/port.c | 32 + 15 files changed, 1826 insertions(+), 1634 deletions(-)
Tested on Turris MOX, no regressions discovered so far.
But patches 06/15 and 14/15 need testing on CN9130-CRB: the SFP cage needs to be tested in 2500base-x mode, and also switching between 2500base-x, sgmii, 5gbase-r and 10gbase-r.
Pali, could you find some time for this? I can direct you about how to do this.
Marek