[net-next,13/15] net: dsa: mt7530: add support for 10G link modes for CPU port

Message ID 89ef48606fdbe896705a57a65a85c22cae01936e.1680180959.git.daniel@makrotopia.org
State New
Headers
Series net: dsa: add support for MT7988 |

Commit Message

Daniel Golle March 30, 2023, 3:23 p.m. UTC
  The built-in switch of the MT7988 SoC is internally connected using
a stateless 10G link. Add support for 10G interface modes to silence
a warning otherwise occurring when the switch driver is setup.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/mt7530.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Arınç ÜNAL April 1, 2023, 8:56 a.m. UTC | #1
On 30.03.2023 18:23, Daniel Golle wrote:
> The built-in switch of the MT7988 SoC is internally connected using
> a stateless 10G link. Add support for 10G interface modes to silence
> a warning otherwise occurring when the switch driver is setup.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
>   drivers/net/dsa/mt7530.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 3a4682e71e746..ac666da2d10dc 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2618,6 +2618,9 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
>   	case PHY_INTERFACE_MODE_1000BASEX:
>   	case PHY_INTERFACE_MODE_2500BASEX:
>   		/* handled in SGMII PCS driver */
> +	case PHY_INTERFACE_MODE_USXGMII:
> +	case PHY_INTERFACE_MODE_10GKR:
> +		/* internal stateless 10G link */
>   		return 0;
>   	default:
>   		return -EINVAL;

I think it'd be better to make this explicitly for the switch in the
MT7988 SoC.

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index e5347dd2521b..f7542c7f60e4 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2666,10 +2665,13 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
  	case PHY_INTERFACE_MODE_1000BASEX:
  	case PHY_INTERFACE_MODE_2500BASEX:
  		/* handled in SGMII PCS driver */
+		return 0;
  	case PHY_INTERFACE_MODE_USXGMII:
  	case PHY_INTERFACE_MODE_10GKR:
-		/* internal stateless 10G link */
-		return 0;
+		if (priv->id == ID_MT7988)
+			/* internal stateless 10G link */
+			return 0;
+
  	default:
  		return -EINVAL;
  	}

Arınç
  
Daniel Golle April 1, 2023, 1:05 p.m. UTC | #2
On Sat, Apr 01, 2023 at 11:56:43AM +0300, Arınç ÜNAL wrote:
> On 30.03.2023 18:23, Daniel Golle wrote:
> > The built-in switch of the MT7988 SoC is internally connected using
> > a stateless 10G link. Add support for 10G interface modes to silence
> > a warning otherwise occurring when the switch driver is setup.
> > 
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> >   drivers/net/dsa/mt7530.c | 7 ++++++-
> >   1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> > index 3a4682e71e746..ac666da2d10dc 100644
> > --- a/drivers/net/dsa/mt7530.c
> > +++ b/drivers/net/dsa/mt7530.c
> > @@ -2618,6 +2618,9 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
> >   	case PHY_INTERFACE_MODE_1000BASEX:
> >   	case PHY_INTERFACE_MODE_2500BASEX:
> >   		/* handled in SGMII PCS driver */
> > +	case PHY_INTERFACE_MODE_USXGMII:
> > +	case PHY_INTERFACE_MODE_10GKR:
> > +		/* internal stateless 10G link */
> >   		return 0;
> >   	default:
> >   		return -EINVAL;
> 
> I think it'd be better to make this explicitly for the switch in the
> MT7988 SoC.

I decided to rather introduce mt7988_mac_config (a noop returning
either 0 or -EINVAL), mt7988_mac_port_get_caps (allowing only USXGMII
and 10000FD) and mt7988_cpu_port_config (setting CPU port bit in
registers but not caring about interface mode and speed other than
USXGMII/10000FD).

The updated commit adding MT7988 is here:
https://github.com/dangowrt/linux/commit/595c940cbee90b5dbdc8173974a007fefe641550

So then I dropped
"net: dsa: mt7530: add support for 10G link modes for CPU port"
because it is no longer needed if all this is done explicitely for MT7988.

> 
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index e5347dd2521b..f7542c7f60e4 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2666,10 +2665,13 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
>  	case PHY_INTERFACE_MODE_1000BASEX:
>  	case PHY_INTERFACE_MODE_2500BASEX:
>  		/* handled in SGMII PCS driver */
> +		return 0;
>  	case PHY_INTERFACE_MODE_USXGMII:
>  	case PHY_INTERFACE_MODE_10GKR:
> -		/* internal stateless 10G link */
> -		return 0;
> +		if (priv->id == ID_MT7988)
> +			/* internal stateless 10G link */
> +			return 0;
> +
>  	default:
>  		return -EINVAL;
>  	}
> 
> Arınç
  

Patch

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 3a4682e71e746..ac666da2d10dc 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2618,6 +2618,9 @@  mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
 	case PHY_INTERFACE_MODE_1000BASEX:
 	case PHY_INTERFACE_MODE_2500BASEX:
 		/* handled in SGMII PCS driver */
+	case PHY_INTERFACE_MODE_USXGMII:
+	case PHY_INTERFACE_MODE_10GKR:
+		/* internal stateless 10G link */
 		return 0;
 	default:
 		return -EINVAL;
@@ -2741,7 +2744,9 @@  static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
 	 * variants.
 	 */
 	if (interface == PHY_INTERFACE_MODE_TRGMII ||
-	    (phy_interface_mode_is_8023z(interface))) {
+	    interface == PHY_INTERFACE_MODE_USXGMII ||
+	    interface == PHY_INTERFACE_MODE_10GKR ||
+	    phy_interface_mode_is_8023z(interface)) {
 		speed = SPEED_1000;
 		duplex = DUPLEX_FULL;
 	}