Message ID | cover.1618227910.git.i.bornyakov@metrotek.ru |
---|---|
Headers | show |
Series | net: phy: marvell-88x2222: a couple of improvements | expand |
On Mon, Apr 12, 2021 at 03:16:59PM +0300, Ivan Bornyakov wrote: > Some SFP modules uses RX_LOS for link indication. In such cases link > will be always up, even without cable connected. RX_LOS changes will > trigger link_up()/link_down() upstream operations. Thus, check that SFP > link is operational before actual read link status. Sorry, but this is not making much sense to me. LOS just indicates some sort of light is coming into the device. You have no idea what sort of light. The transceiver might be able to decode that light and get sync, it might not. It is important that mv2222_read_status() returns the line side status. Has it been able to achieve sync? That should be independent of LOS. Or are you saying the transceiver is reporting sync, despite no light coming in? Andrew
On Tue, Apr 13, 2021 at 01:32:12AM +0200, Marek BehĂșn wrote: > On Mon, 12 Apr 2021 15:16:59 +0300 > Ivan Bornyakov <i.bornyakov@metrotek.ru> wrote: > > > Some SFP modules uses RX_LOS for link indication. In such cases link > > will be always up, even without cable connected. RX_LOS changes will > > trigger link_up()/link_down() upstream operations. Thus, check that SFP > > link is operational before actual read link status. > > > > Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru> > > --- > > drivers/net/phy/marvell-88x2222.c | 26 ++++++++++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > diff --git a/drivers/net/phy/marvell-88x2222.c b/drivers/net/phy/marvell-88x2222.c > > index eca8c2f20684..fb285ac741b2 100644 > > --- a/drivers/net/phy/marvell-88x2222.c > > +++ b/drivers/net/phy/marvell-88x2222.c > > @@ -51,6 +51,7 @@ > > struct mv2222_data { > > phy_interface_t line_interface; > > __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); > > + bool sfp_link; > > }; > > > > /* SFI PMA transmit enable */ > > @@ -148,6 +149,9 @@ static int mv2222_read_status(struct phy_device *phydev) > > phydev->speed = SPEED_UNKNOWN; > > phydev->duplex = DUPLEX_UNKNOWN; > > > > + if (!priv->sfp_link) > > + return 0; > > + > > So if SFP is not used at all, if this PHY is used in a different > usecase, this function will always return 0? Is this correct? > Yes, probably. The thing is that I only have hardware with SFP cages, so I realy don't know if this driver work in other usecases. The good thing about open source is that other developers with different hardware configurations can rework here and there and contribute back. Right? > > if (priv->line_interface == PHY_INTERFACE_MODE_10GBASER) > > link = mv2222_read_status_10g(phydev); > > else > > @@ -446,9 +450,31 @@ static void mv2222_sfp_remove(void *upstream) > > linkmode_zero(priv->supported); > > } > > > > +static void mv2222_sfp_link_up(void *upstream) > > +{ > > + struct phy_device *phydev = upstream; > > + struct mv2222_data *priv; > > + > > + priv = (struct mv2222_data *)phydev->priv; > > + > > + priv->sfp_link = true; > > +} > > + > > +static void mv2222_sfp_link_down(void *upstream) > > +{ > > + struct phy_device *phydev = upstream; > > + struct mv2222_data *priv; > > + > > + priv = (struct mv2222_data *)phydev->priv; > > This cast is redundant since the phydev->priv is (void*). You can cast > (void*) to (struct ... *). > > You can also just use > struct mv2222_data *priv = phydev->priv; > Yeah, I know, but reverse XMAS tree wouldn't line up. > > + > > + priv->sfp_link = false; > > +} > > + > > static const struct sfp_upstream_ops sfp_phy_ops = { > > .module_insert = mv2222_sfp_insert, > > .module_remove = mv2222_sfp_remove, > > + .link_up = mv2222_sfp_link_up, > > + .link_down = mv2222_sfp_link_down, > > .attach = phy_sfp_attach, > > .detach = phy_sfp_detach, > > }; >
On Tue, Apr 13, 2021 at 01:40:32AM +0200, Andrew Lunn wrote: > On Mon, Apr 12, 2021 at 03:16:59PM +0300, Ivan Bornyakov wrote: > > Some SFP modules uses RX_LOS for link indication. In such cases link > > will be always up, even without cable connected. RX_LOS changes will > > trigger link_up()/link_down() upstream operations. Thus, check that SFP > > link is operational before actual read link status. > > Sorry, but this is not making much sense to me. > > LOS just indicates some sort of light is coming into the device. You > have no idea what sort of light. The transceiver might be able to > decode that light and get sync, it might not. It is important that > mv2222_read_status() returns the line side status. Has it been able to > achieve sync? That should be independent of LOS. Or are you saying the > transceiver is reporting sync, despite no light coming in? > > Andrew Yes, with some SFP modules transceiver is reporting sync despite no light coming in. So, the idea is to check that link is somewhat operational before determing line-side status.
On Tue, Apr 13, 2021 at 10:19:30AM +0300, Ivan Bornyakov wrote: > On Tue, Apr 13, 2021 at 01:40:32AM +0200, Andrew Lunn wrote: > > On Mon, Apr 12, 2021 at 03:16:59PM +0300, Ivan Bornyakov wrote: > > > Some SFP modules uses RX_LOS for link indication. In such cases link > > > will be always up, even without cable connected. RX_LOS changes will > > > trigger link_up()/link_down() upstream operations. Thus, check that SFP > > > link is operational before actual read link status. > > > > Sorry, but this is not making much sense to me. > > > > LOS just indicates some sort of light is coming into the device. You > > have no idea what sort of light. The transceiver might be able to > > decode that light and get sync, it might not. It is important that > > mv2222_read_status() returns the line side status. Has it been able to > > achieve sync? That should be independent of LOS. Or are you saying the > > transceiver is reporting sync, despite no light coming in? > > > > Andrew > > Yes, with some SFP modules transceiver is reporting sync despite no > light coming in. So, the idea is to check that link is somewhat > operational before determing line-side status. Indeed - it should be a logical and operation - there is light present _and_ the PHY recognises the signal. This is what the commit achieves, although (iirc) doesn't cater for the case where there is no SFP cage attached. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
On Tue, Apr 13, 2021 at 10:23:48AM +0100, Russell King - ARM Linux admin wrote: > On Tue, Apr 13, 2021 at 10:19:30AM +0300, Ivan Bornyakov wrote: > > On Tue, Apr 13, 2021 at 01:40:32AM +0200, Andrew Lunn wrote: > > > On Mon, Apr 12, 2021 at 03:16:59PM +0300, Ivan Bornyakov wrote: > > > > Some SFP modules uses RX_LOS for link indication. In such cases link > > > > will be always up, even without cable connected. RX_LOS changes will > > > > trigger link_up()/link_down() upstream operations. Thus, check that SFP > > > > link is operational before actual read link status. > > > > > > Sorry, but this is not making much sense to me. > > > > > > LOS just indicates some sort of light is coming into the device. You > > > have no idea what sort of light. The transceiver might be able to > > > decode that light and get sync, it might not. It is important that > > > mv2222_read_status() returns the line side status. Has it been able to > > > achieve sync? That should be independent of LOS. Or are you saying the > > > transceiver is reporting sync, despite no light coming in? > > > > > > Andrew > > > > Yes, with some SFP modules transceiver is reporting sync despite no > > light coming in. So, the idea is to check that link is somewhat > > operational before determing line-side status. > > Indeed - it should be a logical and operation - there is light present > _and_ the PHY recognises the signal. This is what the commit achieves, > although (iirc) doesn't cater for the case where there is no SFP cage > attached. > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! Correct, it does not, I only have HW with SFP cage attached.
On Tue, Apr 13, 2021 at 10:13:49AM +0300, Ivan Bornyakov wrote: > On Tue, Apr 13, 2021 at 01:32:12AM +0200, Marek BehĂșn wrote: > > On Mon, 12 Apr 2021 15:16:59 +0300 > > Ivan Bornyakov <i.bornyakov@metrotek.ru> wrote: > > > > > Some SFP modules uses RX_LOS for link indication. In such cases link > > > will be always up, even without cable connected. RX_LOS changes will > > > trigger link_up()/link_down() upstream operations. Thus, check that SFP > > > link is operational before actual read link status. > > > > > > Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru> > > > --- > > > drivers/net/phy/marvell-88x2222.c | 26 ++++++++++++++++++++++++++ > > > 1 file changed, 26 insertions(+) > > > > > > diff --git a/drivers/net/phy/marvell-88x2222.c b/drivers/net/phy/marvell-88x2222.c > > > index eca8c2f20684..fb285ac741b2 100644 > > > --- a/drivers/net/phy/marvell-88x2222.c > > > +++ b/drivers/net/phy/marvell-88x2222.c > > > @@ -51,6 +51,7 @@ > > > struct mv2222_data { > > > phy_interface_t line_interface; > > > __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); > > > + bool sfp_link; > > > }; > > > > > > /* SFI PMA transmit enable */ > > > @@ -148,6 +149,9 @@ static int mv2222_read_status(struct phy_device *phydev) > > > phydev->speed = SPEED_UNKNOWN; > > > phydev->duplex = DUPLEX_UNKNOWN; > > > > > > + if (!priv->sfp_link) > > > + return 0; > > > + > > > > So if SFP is not used at all, if this PHY is used in a different > > usecase, this function will always return 0? Is this correct? > > > > Yes, probably. The thing is that I only have hardware with SFP cages, so > I realy don't know if this driver work in other usecases. It is O.K, to say you don't know if this will work for other setups, but it is different thing to do something which could potentially break those other setup. Somebody trying to use this without an SFP is going to have a bad experience because of this change. And then they are going to have to try to fix this, potentially breaking your setup. if you truly need this, make it conditional on that you know you have an SFP cage connected. > > > +static void mv2222_sfp_link_down(void *upstream) > > > +{ > > > + struct phy_device *phydev = upstream; > > > + struct mv2222_data *priv; > > > + > > > + priv = (struct mv2222_data *)phydev->priv; > > > > This cast is redundant since the phydev->priv is (void*). You can cast > > (void*) to (struct ... *). > > > > You can also just use > > struct mv2222_data *priv = phydev->priv; > > > > Yeah, I know, but reverse XMAS tree wouldn't line up. Please move the assignment into the body of the function. Andrew
> Indeed - it should be a logical and operation - there is light present > _and_ the PHY recognises the signal. This is what the commit achieves, > although (iirc) doesn't cater for the case where there is no SFP cage > attached. Hi Russell Is there something like this in the marvell10 driver? Also, do you know when there is an SFP cage? Do we need a standardised DT property for this? Andrew
Hi Andrew, On Tue, Apr 13, 2021 at 03:12:05PM +0200, Andrew Lunn wrote: > Is there something like this in the marvell10 driver? No, it doesn't seem to be necessary there - I haven't seen spontaneous link-ups with the 88x3310 there. Even if we did, that would cause other issues beyond a nusience link-up event, as the PHY selects the first media that has link between copper and fiber (and both are present on Macchiatobin platforms.) If the fiber indicates link up, it would prevent a copper connection being established. > Also, do you know when there is an SFP cage? Do we need a standardised > DT property for this? phydev->sfp_bus being non-NULL? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!