lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210413071349.r374hxctgboj7l5a@dhcp-179.ddg>
Date:   Tue, 13 Apr 2021 10:13:49 +0300
From:   Ivan Bornyakov <i.bornyakov@...rotek.ru>
To:     Marek BehĂșn <kabel@...nel.org>
Cc:     system@...rotek.ru, andrew@...n.ch, hkallweit1@...il.com,
        linux@...linux.org.uk, davem@...emloft.net, kuba@...nel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 1/2] net: phy: marvell-88x2222: check that link
 is operational

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@...rotek.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@...rotek.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,
> >  };
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ