From: "Russell King (Oracle)" <linux@armlinux.org.uk> Date: 2021-11-23 09:54:45
Hi all,
In March 2020, phylink gained support to split the PCS support out of
the MAC callbacks. By doing so, a slight behavioural difference was
introduced when a PCS is present, specifically:
1) the call to mac_config() when the link comes up or advertisement
changes were eliminated
2) mac_an_restart() will never be called
3) mac_pcs_get_state() will never be called
The intention was to eventually remove this support once all phylink
users were converted. Unfortunately, this still hasn't happened - and
in some cases, it looks like it may never happen.
Through discussion with Sean Anderson, we now need to allow the PCS to
be optional for modern drivers, so we need a different way to identify
these legacy drivers.
In order to do that, this series of patches introduce a
"legacy_pre_march2020" which is used to allow the old behaviour - in
other words, we get the old behaviour only when there is no PCS and
this flag is true. Otherwise, we get the new behaviour.
I decided to use the date of the change in the flag as just using
"legacy" or "legacy_driver" is too non-descript. An alternative could
be to use the git sha1 hash of the set of changes.
As part of this series, I have consolidated DSA's phylink creation, so
only one place needs maintenance. This reduces the size of subsequent
changes, including further changes I have lined up.
I believe I have added the legacy flag to all the drivers which use
legacy mode - that being the ag71xx, mtk_eth_soc and axienet ethernet
drivers, and many DSA drivers - the ones which need the old behaviour
are identified by having non-NULL phylink_mac_link_state or
phylink_mac_an_restart methods in their dsa_switch_ops structure.
drivers/net/ethernet/atheros/ag71xx.c | 1 +
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 1 +
drivers/net/phy/phylink.c | 32 +++++++++-----
include/linux/phylink.h | 20 +++++++++
net/dsa/dsa_priv.h | 2 +-
net/dsa/port.c | 51 ++++++++++++++++-------
net/dsa/slave.c | 19 ++-------
8 files changed, 86 insertions(+), 44 deletions(-)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:02:45
ag71xx has a PCS, but does not make use of the phylink PCS support.
Mark it was a pre-March 2020 driver.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/ethernet/atheros/ag71xx.c | 1 +
1 file changed, 1 insertion(+)
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:02:45
axienet has a PCS, but does not make use of the phylink PCS support.
Mark it was a pre-March 2020 driver.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 1 +
1 file changed, 1 insertion(+)
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:02:59
Use the legacy flag to indicate whether we should operate in legacy
mode. This allows us to stop using the presence of a PCS as an
indicator to the age of the phylink user, and make PCS presence
optional.
Legacy mode involves:
1) calling mac_config() whenever the link comes up
2) calling mac_config() whenever the inband advertisement changes,
possibly followed by a call to mac_an_restart()
3) making use of mac_an_restart()
4) making use of mac_pcs_get_state()
All the above functionality was moved to a seperate "PCS" block of
operations in March 2020.
Update the documents to indicate that the differences that this flag
makes.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 12 ++++++------
include/linux/phylink.h | 17 +++++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:03:00
Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
the PCS from phylink. This is only supported on non-legacy drivers
where doing so will have no effect on the mac_config() calling
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
@@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);*inmac_prepare()ormac_config()methodsifitisdesiredtodynamically*changethePCS.*-*Pleasenotethattherearebehaviouralchangeswiththemac_config()-*callbackifaPCSispresent(denotinganewersetup)soremovingaPCS-*isnotsupported,andifaPCSisgoingtobeused,itmustberegistered-*bycallingphylink_set_pcs()atthelatestinthefirstmac_config()call.+*Pleasenotethatforlegacyphylinkusers,therearebehaviouralchanges+*withthemac_config()callbackifaPCSispresent(denotinganewersetup)+*soremovingaPCSisnotsupported.IfaPCSisgoingtobeused,itmust+*beregisteredbycallingphylink_set_pcs()atthelatestinthefirst+*mac_config()call.+*+*Formoderndrivers,thismaybecalledwithaNULLpcsargumentto+*disconnectthePCSfromphylink.*/voidphylink_set_pcs(structphylink*pl,structphylink_pcs*pcs){+if(pl->config->legacy_pre_march2020&&pl->pcs&&!pcs){+phylink_warn(pl,+"Removing PCS is not supported in a legacy driver");+return;+}+pl->pcs=pcs;-pl->pcs_ops=pcs->ops;+pl->pcs_ops=pcs?pcs->ops:NULL;}EXPORT_SYMBOL_GPL(phylink_set_pcs);
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:04:04
The code in port.c and slave.c creating the phylink instance is very
similar - let's consolidate this into a single function.
Signed-off-by: Russell King (Oracle) <redacted>
---
net/dsa/dsa_priv.h | 2 +-
net/dsa/port.c | 44 ++++++++++++++++++++++++++++----------------
net/dsa/slave.c | 19 +++----------------
3 files changed, 32 insertions(+), 33 deletions(-)
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:04:41
Add a boolean to phylink_config to indicate whether a driver has not
been updated for the changes in commit 7cceb599d15d ("net: phylink:
avoid mac_config calls"), and thus are reliant on the old behaviour.
We were keying this behaviour on the presence of a PCS, but this
becomes an unreliable indicator when making PCS optional. Hence, we
use a flag instead.
Signed-off-by: Russell King (Oracle) <redacted>
---
include/linux/phylink.h | 3 +++
1 file changed, 3 insertions(+)
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:04:59
As DSA doesn't make use of the PCS support, but it does have PCS, it
must be marked as a pre-March 2020 driver to maintain the old phylink
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
net/dsa/port.c | 7 +++++++
1 file changed, 7 insertions(+)
@@ -1091,6 +1091,13 @@ int dsa_port_phylink_create(struct dsa_port *dp)if(err)mode=PHY_INTERFACE_MODE_NA;+/* Presence of phylink_mac_link_state or phylink_mac_an_restart is+*anindicatorofalegacyphylinkdriver.+*/+if(ds->ops->phylink_mac_link_state||+ds->ops->phylink_mac_an_restart)+dp->pl_config.legacy_pre_march2020=true;+if(ds->ops->phylink_get_interfaces)ds->ops->phylink_get_interfaces(ds,dp->index,dp->pl_config.supported_interfaces);
From: Russell King (Oracle) <hidden> Date: 2021-11-23 10:05:46
mtk_eth_soc has not been updated for commit 7cceb599d15d ("net: phylink:
avoid mac_config calls"), so mark it as a legacy driver.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
1 file changed, 4 insertions(+)
@@ -2923,6 +2923,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)mac->phylink_config.dev=ð->netdev[id]->dev;mac->phylink_config.type=PHYLINK_NETDEV;+/* This driver makes use of state->speed/state->duplex in+*mac_config+*/+mac->phylink_config.legacy_pre_march2020=true;mac->phylink_config.mac_capabilities=MAC_ASYM_PAUSE|MAC_SYM_PAUSE|MAC_10|MAC_100|MAC_1000|MAC_2500FD;
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-11-23 12:10:16
On Tue, Nov 23, 2021 at 10:00:50AM +0000, Russell King (Oracle) wrote:
quoted hunk
Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
the PCS from phylink. This is only supported on non-legacy drivers
where doing so will have no effect on the mac_config() calling
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
@@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);*inmac_prepare()ormac_config()methodsifitisdesiredtodynamically*changethePCS.*-*Pleasenotethattherearebehaviouralchangeswiththemac_config()-*callbackifaPCSispresent(denotinganewersetup)soremovingaPCS-*isnotsupported,andifaPCSisgoingtobeused,itmustberegistered-*bycallingphylink_set_pcs()atthelatestinthefirstmac_config()call.+*Pleasenotethatforlegacyphylinkusers,therearebehaviouralchanges+*withthemac_config()callbackifaPCSispresent(denotinganewersetup)+*soremovingaPCSisnotsupported.IfaPCSisgoingtobeused,itmust+*beregisteredbycallingphylink_set_pcs()atthelatestinthefirst+*mac_config()call.+*+*Formoderndrivers,thismaybecalledwithaNULLpcsargumentto+*disconnectthePCSfromphylink.*/voidphylink_set_pcs(structphylink*pl,structphylink_pcs*pcs){+if(pl->config->legacy_pre_march2020&&pl->pcs&&!pcs){+phylink_warn(pl,+"Removing PCS is not supported in a legacy driver");+return;+}+pl->pcs=pcs;-pl->pcs_ops=pcs->ops;+pl->pcs_ops=pcs?pcs->ops:NULL;}EXPORT_SYMBOL_GPL(phylink_set_pcs);
From: "Russell King (Oracle)" <linux@armlinux.org.uk> Date: 2021-11-23 16:09:48
On Tue, Nov 23, 2021 at 02:08:25PM +0200, Vladimir Oltean wrote:
On Tue, Nov 23, 2021 at 10:00:50AM +0000, Russell King (Oracle) wrote:
quoted
Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
the PCS from phylink. This is only supported on non-legacy drivers
where doing so will have no effect on the mac_config() calling
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
@@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);*inmac_prepare()ormac_config()methodsifitisdesiredtodynamically*changethePCS.*-*Pleasenotethattherearebehaviouralchangeswiththemac_config()-*callbackifaPCSispresent(denotinganewersetup)soremovingaPCS-*isnotsupported,andifaPCSisgoingtobeused,itmustberegistered-*bycallingphylink_set_pcs()atthelatestinthefirstmac_config()call.+*Pleasenotethatforlegacyphylinkusers,therearebehaviouralchanges+*withthemac_config()callbackifaPCSispresent(denotinganewersetup)+*soremovingaPCSisnotsupported.IfaPCSisgoingtobeused,itmust+*beregisteredbycallingphylink_set_pcs()atthelatestinthefirst+*mac_config()call.+*+*Formoderndrivers,thismaybecalledwithaNULLpcsargumentto+*disconnectthePCSfromphylink.*/voidphylink_set_pcs(structphylink*pl,structphylink_pcs*pcs){+if(pl->config->legacy_pre_march2020&&pl->pcs&&!pcs){+phylink_warn(pl,+"Removing PCS is not supported in a legacy driver");+return;+}+pl->pcs=pcs;-pl->pcs_ops=pcs->ops;+pl->pcs_ops=pcs?pcs->ops:NULL;}EXPORT_SYMBOL_GPL(phylink_set_pcs);
From: Sean Anderson <hidden> Date: 2021-11-23 17:32:37
On 11/23/21 11:08 AM, Russell King (Oracle) wrote:
On Tue, Nov 23, 2021 at 02:08:25PM +0200, Vladimir Oltean wrote:
quoted
On Tue, Nov 23, 2021 at 10:00:50AM +0000, Russell King (Oracle) wrote:
quoted
Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
the PCS from phylink. This is only supported on non-legacy drivers
where doing so will have no effect on the mac_config() calling
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
@@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);*inmac_prepare()ormac_config()methodsifitisdesiredtodynamically*changethePCS.*-*Pleasenotethattherearebehaviouralchangeswiththemac_config()-*callbackifaPCSispresent(denotinganewersetup)soremovingaPCS-*isnotsupported,andifaPCSisgoingtobeused,itmustberegistered-*bycallingphylink_set_pcs()atthelatestinthefirstmac_config()call.+*Pleasenotethatforlegacyphylinkusers,therearebehaviouralchanges+*withthemac_config()callbackifaPCSispresent(denotinganewersetup)+*soremovingaPCSisnotsupported.IfaPCSisgoingtobeused,itmust+*beregisteredbycallingphylink_set_pcs()atthelatestinthefirst+*mac_config()call.+*+*Formoderndrivers,thismaybecalledwithaNULLpcsargumentto+*disconnectthePCSfromphylink.*/voidphylink_set_pcs(structphylink*pl,structphylink_pcs*pcs){+if(pl->config->legacy_pre_march2020&&pl->pcs&&!pcs){+phylink_warn(pl,+"Removing PCS is not supported in a legacy driver");+return;+}+pl->pcs=pcs;-pl->pcs_ops=pcs->ops;+pl->pcs_ops=pcs?pcs->ops:NULL;}EXPORT_SYMBOL_GPL(phylink_set_pcs);--
My original feedback was regarding selecting the correct PCS to use. In
response to the question "What PCS do you want to use for this phy
interface mode?" a valid response is "I don't need a PCS," even if for a
different mode a valid response might be "Please use X PCS." Because
this function is used in validate(), it is necessary to evaluate
"what-if" scenarios, even if a scenario requiring a PCS and one
requiring no PCS would never actually be configured.
Typically the PCS is physically attached to the next layer in the link,
even if the hardware could be configured not to use the PCS. So it does
not usually make sense to configure a link to use modes both requiring a
PCS and requiring no PCS. However, it is possible that such a system
could exist. Most systems should use `phy-mode` to restrict the phy
interfaces modes to whatever makes sense for the board. I think Marek's
series (and specifically [1]) is an good step in this regard.
--Sean
[1] https://lore.kernel.org/netdev/20211123164027.15618-5-kabel@kernel.org/
From: "Russell King (Oracle)" <linux@armlinux.org.uk> Date: 2021-11-23 18:08:03
On Tue, Nov 23, 2021 at 10:00:34AM +0000, Russell King (Oracle) wrote:
ag71xx has a PCS, but does not make use of the phylink PCS support.
Mark it was a pre-March 2020 driver.
Signed-off-by: Russell King (Oracle) <redacted>
Hi,
I've just been looking closer at this driver, and it seems that we can
drop the "legacy_pre_march2020" flag, and in doing so, delete the
ag71xx_mac_pcs_get_state and ag71xx_mac_an_restart functions entirely,
removing them from ag71xx_phylink_mac_ops.
Should this driver need to deal with the PCS - in other words, to
modify the advertisement, then it will need to make use of the
phylink_pcs support.
I'll send a v2 in a day or two.
Thanks!
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-11-23 18:16:44
On Tue, Nov 23, 2021 at 12:30:33PM -0500, Sean Anderson wrote:
On 11/23/21 11:08 AM, Russell King (Oracle) wrote:
quoted
On Tue, Nov 23, 2021 at 02:08:25PM +0200, Vladimir Oltean wrote:
quoted
On Tue, Nov 23, 2021 at 10:00:50AM +0000, Russell King (Oracle) wrote:
quoted
Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
the PCS from phylink. This is only supported on non-legacy drivers
where doing so will have no effect on the mac_config() calling
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
@@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);*inmac_prepare()ormac_config()methodsifitisdesiredtodynamically*changethePCS.*-*Pleasenotethattherearebehaviouralchangeswiththemac_config()-*callbackifaPCSispresent(denotinganewersetup)soremovingaPCS-*isnotsupported,andifaPCSisgoingtobeused,itmustberegistered-*bycallingphylink_set_pcs()atthelatestinthefirstmac_config()call.+*Pleasenotethatforlegacyphylinkusers,therearebehaviouralchanges+*withthemac_config()callbackifaPCSispresent(denotinganewersetup)+*soremovingaPCSisnotsupported.IfaPCSisgoingtobeused,itmust+*beregisteredbycallingphylink_set_pcs()atthelatestinthefirst+*mac_config()call.+*+*Formoderndrivers,thismaybecalledwithaNULLpcsargumentto+*disconnectthePCSfromphylink.*/voidphylink_set_pcs(structphylink*pl,structphylink_pcs*pcs){+if(pl->config->legacy_pre_march2020&&pl->pcs&&!pcs){+phylink_warn(pl,+"Removing PCS is not supported in a legacy driver");+return;+}+pl->pcs=pcs;-pl->pcs_ops=pcs->ops;+pl->pcs_ops=pcs?pcs->ops:NULL;}EXPORT_SYMBOL_GPL(phylink_set_pcs);--
My original feedback was regarding selecting the correct PCS to use. In
response to the question "What PCS do you want to use for this phy
interface mode?" a valid response is "I don't need a PCS," even if for a
different mode a valid response might be "Please use X PCS."
Yes, but that is not a reason why you'd want to _remove_ one. Just don't
call phylink_set_pcs() in the first place, there you go, no PCS.
Because this function is used in validate(), it is necessary to
evaluate "what-if" scenarios, even if a scenario requiring a PCS and
one requiring no PCS would never actually be configured.
Yes, but on the same port on the same board? The MAC-side PCS is an
integral part of serial Ethernet links, be it modeled as a discrete part
by hardware manufacturers or not. We are effectively talking about a
situation where a serial link would become parallel, or the other way
around. Have you seen such a thing?
Typically the PCS is physically attached to the next layer in the link,
even if the hardware could be configured not to use the PCS. So it does
not usually make sense to configure a link to use modes both requiring a
PCS and requiring no PCS. However, it is possible that such a system
could exist. Most systems should use `phy-mode` to restrict the phy
interfaces modes to whatever makes sense for the board. I think Marek's
series (and specifically [1]) is an good step in this regard.
--Sean
[1] https://lore.kernel.org/netdev/20211123164027.15618-5-kabel@kernel.org/
Marek's patches are for reconfiguring the SERDES protocol on the same
lanes. But the lanes are still physically there, and you'd need a PCS to
talk to them no matter what you do, they won't magically turn into RGMII.
If you need to switch the MAC PCS you're configuring with another MAC
PCS (within the same hardware block more or less) due to the fact that
the SERDES protocol is changing, that doesn't count as removing the PCS,
does it? Or what are you thinking of when you say PCS? Phylink doesn't
support any other kind of PCS than a MAC-side PCS.
From: Sean Anderson <hidden> Date: 2021-11-23 19:05:57
On 11/23/21 1:15 PM, Vladimir Oltean wrote:
On Tue, Nov 23, 2021 at 12:30:33PM -0500, Sean Anderson wrote:
quoted
On 11/23/21 11:08 AM, Russell King (Oracle) wrote:
quoted
On Tue, Nov 23, 2021 at 02:08:25PM +0200, Vladimir Oltean wrote:
quoted
On Tue, Nov 23, 2021 at 10:00:50AM +0000, Russell King (Oracle) wrote:
quoted
Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
the PCS from phylink. This is only supported on non-legacy drivers
where doing so will have no effect on the mac_config() calling
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
@@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);*inmac_prepare()ormac_config()methodsifitisdesiredtodynamically*changethePCS.*-*Pleasenotethattherearebehaviouralchangeswiththemac_config()-*callbackifaPCSispresent(denotinganewersetup)soremovingaPCS-*isnotsupported,andifaPCSisgoingtobeused,itmustberegistered-*bycallingphylink_set_pcs()atthelatestinthefirstmac_config()call.+*Pleasenotethatforlegacyphylinkusers,therearebehaviouralchanges+*withthemac_config()callbackifaPCSispresent(denotinganewersetup)+*soremovingaPCSisnotsupported.IfaPCSisgoingtobeused,itmust+*beregisteredbycallingphylink_set_pcs()atthelatestinthefirst+*mac_config()call.+*+*Formoderndrivers,thismaybecalledwithaNULLpcsargumentto+*disconnectthePCSfromphylink.*/voidphylink_set_pcs(structphylink*pl,structphylink_pcs*pcs){+if(pl->config->legacy_pre_march2020&&pl->pcs&&!pcs){+phylink_warn(pl,+"Removing PCS is not supported in a legacy driver");+return;+}+pl->pcs=pcs;-pl->pcs_ops=pcs->ops;+pl->pcs_ops=pcs?pcs->ops:NULL;}EXPORT_SYMBOL_GPL(phylink_set_pcs);--
My original feedback was regarding selecting the correct PCS to use. In
response to the question "What PCS do you want to use for this phy
interface mode?" a valid response is "I don't need a PCS," even if for a
different mode a valid response might be "Please use X PCS."
Yes, but that is not a reason why you'd want to _remove_ one. Just don't
call phylink_set_pcs() in the first place, there you go, no PCS.
Yeah.
quoted
Because this function is used in validate(), it is necessary to
evaluate "what-if" scenarios, even if a scenario requiring a PCS and
one requiring no PCS would never actually be configured.
Yes, but on the same port on the same board? The MAC-side PCS is an
integral part of serial Ethernet links, be it modeled as a discrete part
by hardware manufacturers or not. We are effectively talking about a
situation where a serial link would become parallel, or the other way
around. Have you seen such a thing?
I have not. It's certainly possible to create (since the serial link
often uses different physical pins from the parallel link). I think
we can cross that bridge if/when we ever come to it.
quoted
Typically the PCS is physically attached to the next layer in the link,
even if the hardware could be configured not to use the PCS. So it does
not usually make sense to configure a link to use modes both requiring a
PCS and requiring no PCS. However, it is possible that such a system
could exist. Most systems should use `phy-mode` to restrict the phy
interfaces modes to whatever makes sense for the board. I think Marek's
series (and specifically [1]) is an good step in this regard.
--Sean
[1] https://lore.kernel.org/netdev/20211123164027.15618-5-kabel@kernel.org/
Marek's patches are for reconfiguring the SERDES protocol on the same
lanes. But the lanes are still physically there, and you'd need a PCS to
talk to them no matter what you do, they won't magically turn into RGMII.
If you need to switch the MAC PCS you're configuring with another MAC
PCS (within the same hardware block more or less) due to the fact that
the SERDES protocol is changing, that doesn't count as removing the PCS,
does it? Or what are you thinking of when you say PCS? Phylink doesn't
support any other kind of PCS than a MAC-side PCS.
I mean that with that patch applied, phylink will no longer try and
validate modes which aren't supported on a particular board (see
phylink_validate_any). Although, it looks like set_pcs never was called
in the validate path in the first place (looks like I misremembered).
--Sean
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-11-23 19:31:44
On Tue, Nov 23, 2021 at 02:04:03PM -0500, Sean Anderson wrote:
On 11/23/21 1:15 PM, Vladimir Oltean wrote:
quoted
On Tue, Nov 23, 2021 at 12:30:33PM -0500, Sean Anderson wrote:
quoted
On 11/23/21 11:08 AM, Russell King (Oracle) wrote:
quoted
On Tue, Nov 23, 2021 at 02:08:25PM +0200, Vladimir Oltean wrote:
quoted
On Tue, Nov 23, 2021 at 10:00:50AM +0000, Russell King (Oracle) wrote:
quoted
Allow phylink_set_pcs() to be called with a NULL pcs argument to remove
the PCS from phylink. This is only supported on non-legacy drivers
where doing so will have no effect on the mac_config() calling
behaviour.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/phy/phylink.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
@@ -1196,15 +1196,25 @@ EXPORT_SYMBOL_GPL(phylink_create);*inmac_prepare()ormac_config()methodsifitisdesiredtodynamically*changethePCS.*-*Pleasenotethattherearebehaviouralchangeswiththemac_config()-*callbackifaPCSispresent(denotinganewersetup)soremovingaPCS-*isnotsupported,andifaPCSisgoingtobeused,itmustberegistered-*bycallingphylink_set_pcs()atthelatestinthefirstmac_config()call.+*Pleasenotethatforlegacyphylinkusers,therearebehaviouralchanges+*withthemac_config()callbackifaPCSispresent(denotinganewersetup)+*soremovingaPCSisnotsupported.IfaPCSisgoingtobeused,itmust+*beregisteredbycallingphylink_set_pcs()atthelatestinthefirst+*mac_config()call.+*+*Formoderndrivers,thismaybecalledwithaNULLpcsargumentto+*disconnectthePCSfromphylink.*/voidphylink_set_pcs(structphylink*pl,structphylink_pcs*pcs){+if(pl->config->legacy_pre_march2020&&pl->pcs&&!pcs){+phylink_warn(pl,+"Removing PCS is not supported in a legacy driver");+return;+}+pl->pcs=pcs;-pl->pcs_ops=pcs->ops;+pl->pcs_ops=pcs?pcs->ops:NULL;}EXPORT_SYMBOL_GPL(phylink_set_pcs);--
My original feedback was regarding selecting the correct PCS to use. In
response to the question "What PCS do you want to use for this phy
interface mode?" a valid response is "I don't need a PCS," even if for a
different mode a valid response might be "Please use X PCS."
Yes, but that is not a reason why you'd want to _remove_ one. Just don't
call phylink_set_pcs() in the first place, there you go, no PCS.
Yeah.
quoted
quoted
Because this function is used in validate(), it is necessary to
evaluate "what-if" scenarios, even if a scenario requiring a PCS and
one requiring no PCS would never actually be configured.
Yes, but on the same port on the same board? The MAC-side PCS is an
integral part of serial Ethernet links, be it modeled as a discrete part
by hardware manufacturers or not. We are effectively talking about a
situation where a serial link would become parallel, or the other way
around. Have you seen such a thing?
I have not. It's certainly possible to create (since the serial link
often uses different physical pins from the parallel link). I think
we can cross that bridge if/when we ever come to it.
So what do you mean, something like a MAC which can be routed dynamically
via pinctrl either to RGMII or to a SERDES lane? I would expect that
would require rather intricate interaction with the net device driver.
Can that be done today from user space, even in principle?
quoted
quoted
Typically the PCS is physically attached to the next layer in the link,
even if the hardware could be configured not to use the PCS. So it does
not usually make sense to configure a link to use modes both requiring a
PCS and requiring no PCS. However, it is possible that such a system
could exist. Most systems should use `phy-mode` to restrict the phy
interfaces modes to whatever makes sense for the board. I think Marek's
series (and specifically [1]) is an good step in this regard.
--Sean
[1] https://lore.kernel.org/netdev/20211123164027.15618-5-kabel@kernel.org/
Marek's patches are for reconfiguring the SERDES protocol on the same
lanes. But the lanes are still physically there, and you'd need a PCS to
talk to them no matter what you do, they won't magically turn into RGMII.
If you need to switch the MAC PCS you're configuring with another MAC
PCS (within the same hardware block more or less) due to the fact that
the SERDES protocol is changing, that doesn't count as removing the PCS,
does it? Or what are you thinking of when you say PCS? Phylink doesn't
support any other kind of PCS than a MAC-side PCS.
I mean that with that patch applied, phylink will no longer try and
validate modes which aren't supported on a particular board (see
phylink_validate_any). Although, it looks like set_pcs never was called
in the validate path in the first place (looks like I misremembered).
Sorry if you feel like I am asking too many questions. I just want to
understand what I'm being asked to review here :)
So going back to the initial question. What use case do these patches
help to make some progress with?
As far as I understand, being able to call phylink_set_pcs(NULL) is
basically the end goal of it. Sorry if I'm misinterpreting, Russell says
in the cover letter that "we now need to allow the PCS to be optional
for modern drivers". I really don't know how to interpret what
"optional" means. Just judging from that phrase, I don't interpret
"optional" as "having the ability to remove it dynamically", but rather
"the same driver can either interact with phylink using a pcs [on some
ports] or without a pcs [on other ports]". But that deeply confuses me
because that's already supported, and many drivers make use of that
ability already, this is why the pl->pcs_ops checks are there.
From: "Russell King (Oracle)" <linux@armlinux.org.uk> Date: 2021-11-23 19:51:57
On Tue, Nov 23, 2021 at 09:30:17PM +0200, Vladimir Oltean wrote:
Sorry if you feel like I am asking too many questions. I just want to
understand what I'm being asked to review here :)
So going back to the initial question. What use case do these patches
help to make some progress with?
If we exclude patch 8, this series:
1) identifies all those drivers that are reliant on the legacy behaviour
of phylink, which can then be targetted for modernisation - some of
which may be trivial to do. ag71xx and axienet have turned out to be
two drivers that can be trivially converted.
2) hopefully stops the legacy use finding its way into new drivers by
making it easier to spot in review, but hopefully people will realise
that setting the legacy flag in their driver to use the old hooks is
something they probably want to avoid.
3) gives consistent phylink behaviour to modern drivers which may or
may not decide to register a PCS with phylink.
(3) is probably the most important point for any driver that registers
a PCS conditionally. Right now, any driver that does this gets a
slightly different behaviour from phylink as detailed in patch 7.
I would like to remove the legacy code and old .mac_pcs_get_state and
.mac_an_restart callbacks some day...
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!