2018-12-11 16:36:05

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

The mvpp2_phylink_validate() function sets all modes that are
supported by a given PPv2 port. A recent change made all ports to
advertise they support 10G modes in certain cases. This is not true,
as only the port #0 can do so. This patch fixes it.

Fixes: 01b3fd5ac97c ("net: mvpp2: fix detection of 10G SFP modules")
Cc: Baruch Siach <[email protected]>
Signed-off-by: Antoine Tenart <[email protected]>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 125ea99418df..88aa488054a8 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -4405,12 +4405,14 @@ static void mvpp2_phylink_validate(struct net_device *dev,
case PHY_INTERFACE_MODE_10GKR:
case PHY_INTERFACE_MODE_XAUI:
case PHY_INTERFACE_MODE_NA:
- phylink_set(mask, 10000baseCR_Full);
- phylink_set(mask, 10000baseSR_Full);
- phylink_set(mask, 10000baseLR_Full);
- phylink_set(mask, 10000baseLRM_Full);
- phylink_set(mask, 10000baseER_Full);
- phylink_set(mask, 10000baseKR_Full);
+ if (port->gop_id == 0) {
+ phylink_set(mask, 10000baseCR_Full);
+ phylink_set(mask, 10000baseSR_Full);
+ phylink_set(mask, 10000baseLR_Full);
+ phylink_set(mask, 10000baseLRM_Full);
+ phylink_set(mask, 10000baseER_Full);
+ phylink_set(mask, 10000baseKR_Full);
+ }
/* Fall-through */
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
--
2.19.2



2018-12-11 17:21:15

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

On Tue, Dec 11, 2018 at 05:32:28PM +0100, Antoine Tenart wrote:
> The mvpp2_phylink_validate() function sets all modes that are
> supported by a given PPv2 port. A recent change made all ports to
> advertise they support 10G modes in certain cases. This is not true,
> as only the port #0 can do so. This patch fixes it.
>
> Fixes: 01b3fd5ac97c ("net: mvpp2: fix detection of 10G SFP modules")
> Cc: Baruch Siach <[email protected]>
> Signed-off-by: Antoine Tenart <[email protected]>
> ---
> drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 125ea99418df..88aa488054a8 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -4405,12 +4405,14 @@ static void mvpp2_phylink_validate(struct net_device *dev,
> case PHY_INTERFACE_MODE_10GKR:
> case PHY_INTERFACE_MODE_XAUI:

Are these modes supported on anything except port 0? If not, you
should be rejecting these, rather than just treating them as RGMII.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

2018-12-11 17:56:57

by Baruch Siach

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

Hi Russell, Antoine,

Russell King - ARM Linux writes:
> On Tue, Dec 11, 2018 at 05:32:28PM +0100, Antoine Tenart wrote:
>> The mvpp2_phylink_validate() function sets all modes that are
>> supported by a given PPv2 port. A recent change made all ports to
>> advertise they support 10G modes in certain cases. This is not true,
>> as only the port #0 can do so. This patch fixes it.
>>
>> Fixes: 01b3fd5ac97c ("net: mvpp2: fix detection of 10G SFP modules")
>> Cc: Baruch Siach <[email protected]>
>> Signed-off-by: Antoine Tenart <[email protected]>
>> ---
>> drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
>> index 125ea99418df..88aa488054a8 100644
>> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
>> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
>> @@ -4405,12 +4405,14 @@ static void mvpp2_phylink_validate(struct net_device *dev,
>> case PHY_INTERFACE_MODE_10GKR:
>> case PHY_INTERFACE_MODE_XAUI:
>
> Are these modes supported on anything except port 0? If not, you
> should be rejecting these, rather than just treating them as RGMII.

That is, something like this, right?

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 125ea99418df..04cb0241ca2b 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -4404,13 +4404,18 @@ static void mvpp2_phylink_validate(struct net_device *dev,
switch (state->interface) {
case PHY_INTERFACE_MODE_10GKR:
case PHY_INTERFACE_MODE_XAUI:
+ if (port->gop_id != 0)
+ goto empty_set;
+ /* Fall-through */
case PHY_INTERFACE_MODE_NA:
- phylink_set(mask, 10000baseCR_Full);
- phylink_set(mask, 10000baseSR_Full);
- phylink_set(mask, 10000baseLR_Full);
- phylink_set(mask, 10000baseLRM_Full);
- phylink_set(mask, 10000baseER_Full);
- phylink_set(mask, 10000baseKR_Full);
+ if (port->gop_id == 0) {
+ phylink_set(mask, 10000baseCR_Full);
+ phylink_set(mask, 10000baseSR_Full);
+ phylink_set(mask, 10000baseLR_Full);
+ phylink_set(mask, 10000baseLRM_Full);
+ phylink_set(mask, 10000baseER_Full);
+ phylink_set(mask, 10000baseKR_Full);
+ }
/* Fall-through */
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:

baruch

--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -

2018-12-11 18:53:51

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

On Tue, Dec 11, 2018 at 07:53:42PM +0200, Baruch Siach wrote:
> That is, something like this, right?
>
> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 125ea99418df..04cb0241ca2b 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -4404,13 +4404,18 @@ static void mvpp2_phylink_validate(struct net_device *dev,
> switch (state->interface) {
> case PHY_INTERFACE_MODE_10GKR:
> case PHY_INTERFACE_MODE_XAUI:
> + if (port->gop_id != 0)
> + goto empty_set;
> + /* Fall-through */
> case PHY_INTERFACE_MODE_NA:
> - phylink_set(mask, 10000baseCR_Full);
> - phylink_set(mask, 10000baseSR_Full);
> - phylink_set(mask, 10000baseLR_Full);
> - phylink_set(mask, 10000baseLRM_Full);
> - phylink_set(mask, 10000baseER_Full);
> - phylink_set(mask, 10000baseKR_Full);
> + if (port->gop_id == 0) {
> + phylink_set(mask, 10000baseCR_Full);
> + phylink_set(mask, 10000baseSR_Full);
> + phylink_set(mask, 10000baseLR_Full);
> + phylink_set(mask, 10000baseLRM_Full);
> + phylink_set(mask, 10000baseER_Full);
> + phylink_set(mask, 10000baseKR_Full);
> + }
> /* Fall-through */
> case PHY_INTERFACE_MODE_RGMII:
> case PHY_INTERFACE_MODE_RGMII_ID:
>

Yep, looks fine to me, thanks.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

2018-12-11 21:13:37

by Stefan Chulski

[permalink] [raw]
Subject: RE: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports



> -----Original Message-----
> From: [email protected] <[email protected]>
> On Behalf Of Russell King - ARM Linux
> Sent: Tuesday, December 11, 2018 6:37 PM
> To: Antoine Tenart <[email protected]>
> Cc: [email protected]; [email protected]; linux-
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; Nadav Haklai <[email protected]>; Stefan
> Chulski <[email protected]>; Yan Markman <[email protected]>;
> [email protected]; Baruch Siach <[email protected]>
> Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all
> ports
>
> On Tue, Dec 11, 2018 at 05:32:28PM +0100, Antoine Tenart wrote:
> > The mvpp2_phylink_validate() function sets all modes that are
> > supported by a given PPv2 port. A recent change made all ports to
> > advertise they support 10G modes in certain cases. This is not true,
> > as only the port #0 can do so. This patch fixes it.
> >
> > Fixes: 01b3fd5ac97c ("net: mvpp2: fix detection of 10G SFP modules")
> > Cc: Baruch Siach <[email protected]>
> > Signed-off-by: Antoine Tenart <[email protected]>
> > ---
> > drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 14 ++++++++------
> > 1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > index 125ea99418df..88aa488054a8 100644
> > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > @@ -4405,12 +4405,14 @@ static void mvpp2_phylink_validate(struct
> net_device *dev,
> > case PHY_INTERFACE_MODE_10GKR:
> > case PHY_INTERFACE_MODE_XAUI:
>
> Are these modes supported on anything except port 0? If not, you should be
> rejecting these, rather than just treating them as RGMII.

In CP115(which has PPv2) PHY_INTERFACE_MODE_10GKR supported on ports 0 and 1
PHY_INTERFACE_MODE_XAUI/PHY_INTERFACE_MODE_RXAUI supported only on port 0.

Best Regards.

2018-12-12 09:32:54

by Antoine Tenart

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

Hi Russell, Baruch,

On Tue, Dec 11, 2018 at 06:51:56PM +0000, Russell King - ARM Linux wrote:
> On Tue, Dec 11, 2018 at 07:53:42PM +0200, Baruch Siach wrote:
> > That is, something like this, right?
> >
> > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > index 125ea99418df..04cb0241ca2b 100644
> > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > @@ -4404,13 +4404,18 @@ static void mvpp2_phylink_validate(struct net_device *dev,
> > switch (state->interface) {
> > case PHY_INTERFACE_MODE_10GKR:
> > case PHY_INTERFACE_MODE_XAUI:
> > + if (port->gop_id != 0)
> > + goto empty_set;
> > + /* Fall-through */
> > case PHY_INTERFACE_MODE_NA:
> > - phylink_set(mask, 10000baseCR_Full);
> > - phylink_set(mask, 10000baseSR_Full);
> > - phylink_set(mask, 10000baseLR_Full);
> > - phylink_set(mask, 10000baseLRM_Full);
> > - phylink_set(mask, 10000baseER_Full);
> > - phylink_set(mask, 10000baseKR_Full);
> > + if (port->gop_id == 0) {
> > + phylink_set(mask, 10000baseCR_Full);
> > + phylink_set(mask, 10000baseSR_Full);
> > + phylink_set(mask, 10000baseLR_Full);
> > + phylink_set(mask, 10000baseLRM_Full);
> > + phylink_set(mask, 10000baseER_Full);
> > + phylink_set(mask, 10000baseKR_Full);
> > + }
> > /* Fall-through */
> > case PHY_INTERFACE_MODE_RGMII:
> > case PHY_INTERFACE_MODE_RGMII_ID:
> >
>
> Yep, looks fine to me, thanks.

This looks good, thanks! I'll send a v2.

Antoine

--
Antoine T?nart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

2018-12-12 09:33:44

by Antoine Tenart

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

Hi Stefan,

On Tue, Dec 11, 2018 at 09:11:31PM +0000, Stefan Chulski wrote:
>
> >
> > Are these modes supported on anything except port 0? If not, you should be
> > rejecting these, rather than just treating them as RGMII.
>
> In CP115(which has PPv2) PHY_INTERFACE_MODE_10GKR supported on ports 0 and 1
> PHY_INTERFACE_MODE_XAUI/PHY_INTERFACE_MODE_RXAUI supported only on port 0.

That's right. But I think we need to first fix this, and then when
adding support for the cp115 we'll rework this. We will need a way to
differentiate the CP110 PPv2 from the CP115 PPv2.

Thanks!
Antoine

--
Antoine T?nart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

2018-12-12 14:16:20

by Antoine Tenart

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

Hi,

On Wed, Dec 12, 2018 at 10:30:33AM +0100, Antoine Tenart wrote:
> On Tue, Dec 11, 2018 at 06:51:56PM +0000, Russell King - ARM Linux wrote:
> > On Tue, Dec 11, 2018 at 07:53:42PM +0200, Baruch Siach wrote:
> > > That is, something like this, right?
> > >
> > > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > index 125ea99418df..04cb0241ca2b 100644
> > > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > @@ -4404,13 +4404,18 @@ static void mvpp2_phylink_validate(struct net_device *dev,
> > > switch (state->interface) {
> > > case PHY_INTERFACE_MODE_10GKR:
> > > case PHY_INTERFACE_MODE_XAUI:
> > > + if (port->gop_id != 0)
> > > + goto empty_set;
> > > + /* Fall-through */
> > > case PHY_INTERFACE_MODE_NA:
> > > - phylink_set(mask, 10000baseCR_Full);
> > > - phylink_set(mask, 10000baseSR_Full);
> > > - phylink_set(mask, 10000baseLR_Full);
> > > - phylink_set(mask, 10000baseLRM_Full);
> > > - phylink_set(mask, 10000baseER_Full);
> > > - phylink_set(mask, 10000baseKR_Full);
> > > + if (port->gop_id == 0) {
> > > + phylink_set(mask, 10000baseCR_Full);
> > > + phylink_set(mask, 10000baseSR_Full);
> > > + phylink_set(mask, 10000baseLR_Full);
> > > + phylink_set(mask, 10000baseLRM_Full);
> > > + phylink_set(mask, 10000baseER_Full);
> > > + phylink_set(mask, 10000baseKR_Full);
> > > + }
> > > /* Fall-through */
> > > case PHY_INTERFACE_MODE_RGMII:
> > > case PHY_INTERFACE_MODE_RGMII_ID:
> > >
> >
> > Yep, looks fine to me, thanks.
>
> This looks good, thanks! I'll send a v2.

Well, I just got back to this, and looking at the beginning of the
validate function invalid modes are already checked. So we do already
have:

case PHY_INTERFACE_MODE_10GKR:
case PHY_INTERFACE_MODE_XAUI:
if (port->gop_id != 0)
goto empty_set;
break;

So it turns out the fix can be applied as-is.

Thanks!
Antoine

--
Antoine T?nart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

2018-12-12 14:38:19

by Baruch Siach

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

Hi Antoine,

On Wed, Dec 12, 2018 at 03:14:51PM +0100, Antoine Tenart wrote:
> On Wed, Dec 12, 2018 at 10:30:33AM +0100, Antoine Tenart wrote:
> > On Tue, Dec 11, 2018 at 06:51:56PM +0000, Russell King - ARM Linux wrote:
> > > On Tue, Dec 11, 2018 at 07:53:42PM +0200, Baruch Siach wrote:
> > > > That is, something like this, right?
> > > >
> > > > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > > index 125ea99418df..04cb0241ca2b 100644
> > > > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > > @@ -4404,13 +4404,18 @@ static void mvpp2_phylink_validate(struct net_device *dev,
> > > > switch (state->interface) {
> > > > case PHY_INTERFACE_MODE_10GKR:
> > > > case PHY_INTERFACE_MODE_XAUI:
> > > > + if (port->gop_id != 0)
> > > > + goto empty_set;
> > > > + /* Fall-through */
> > > > case PHY_INTERFACE_MODE_NA:
> > > > - phylink_set(mask, 10000baseCR_Full);
> > > > - phylink_set(mask, 10000baseSR_Full);
> > > > - phylink_set(mask, 10000baseLR_Full);
> > > > - phylink_set(mask, 10000baseLRM_Full);
> > > > - phylink_set(mask, 10000baseER_Full);
> > > > - phylink_set(mask, 10000baseKR_Full);
> > > > + if (port->gop_id == 0) {
> > > > + phylink_set(mask, 10000baseCR_Full);
> > > > + phylink_set(mask, 10000baseSR_Full);
> > > > + phylink_set(mask, 10000baseLR_Full);
> > > > + phylink_set(mask, 10000baseLRM_Full);
> > > > + phylink_set(mask, 10000baseER_Full);
> > > > + phylink_set(mask, 10000baseKR_Full);
> > > > + }
> > > > /* Fall-through */
> > > > case PHY_INTERFACE_MODE_RGMII:
> > > > case PHY_INTERFACE_MODE_RGMII_ID:
> > > >
> > >
> > > Yep, looks fine to me, thanks.
> >
> > This looks good, thanks! I'll send a v2.
>
> Well, I just got back to this, and looking at the beginning of the
> validate function invalid modes are already checked. So we do already
> have:
>
> case PHY_INTERFACE_MODE_10GKR:
> case PHY_INTERFACE_MODE_XAUI:
> if (port->gop_id != 0)
> goto empty_set;
> break;
>
> So it turns out the fix can be applied as-is.

Right. I should have known that. Thanks for the fix.

baruch

--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -

2018-12-18 23:41:26

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net] net: mvpp2: 10G modes aren't supported on all ports

From: Antoine Tenart <[email protected]>
Date: Tue, 11 Dec 2018 17:32:28 +0100

> The mvpp2_phylink_validate() function sets all modes that are
> supported by a given PPv2 port. A recent change made all ports to
> advertise they support 10G modes in certain cases. This is not true,
> as only the port #0 can do so. This patch fixes it.
>
> Fixes: 01b3fd5ac97c ("net: mvpp2: fix detection of 10G SFP modules")
> Cc: Baruch Siach <[email protected]>
> Signed-off-by: Antoine Tenart <[email protected]>

Applied, thank you.