Subject: Re: [PATCH RFC net-next 2/6] net: dsa: mv88e6xxx: report the default interface mode for the port

From: Marek Behún <[email-masked]>
Date: Fri, 1 Jul 2022 21:25:56 +0200

On Wed, 29 Jun 2022 13:51:27 +0100
"Russell King (Oracle)" <[email-masked]> wrote:

> Report the maximum speed interface mode for the port, or if we don't
> have that information, the hardware configured interface mode for
> the port.
> 
> This allows phylink to know which interface mode CPU and DSA ports
> are operating, which will be necessary when we want to select the
> maximum speed for the port (required for such ports without a PHY or
> fixed-link specified in firmware.)
> 
> Signed-off-by: Russell King (Oracle) <[email-masked]>
> ---
>  drivers/net/dsa/mv88e6xxx/chip.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index f98be98551ef..1c6b4b00d58d 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -823,6 +823,7 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port,
>  			       phy_interface_t *default_interface)
>  {
>  	struct mv88e6xxx_chip *chip = ds->priv;
> +	u8 cmode = chip->ports[port].cmode;
>  
>  	chip->info->ops->phylink_get_caps(chip, port, config);
>  
> @@ -830,6 +831,14 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port,
>  	if (mv88e6xxx_phy_is_internal(ds, port))
>  		__set_bit(PHY_INTERFACE_MODE_GMII,
>  			  config->supported_interfaces);
> +
> +	if (chip->info->ops->port_max_speed_mode)
> +		*default_interface = chip->info->ops->port_max_speed_mode(port);
> +	else if (cmode < ARRAY_SIZE(mv88e6xxx_phy_interface_modes) &&
> +		 mv88e6xxx_phy_interface_modes[cmode])
> +		*default_interface = mv88e6xxx_phy_interface_modes[cmode];
> +	else if (cmode == MV88E6XXX_PORT_STS_CMODE_RGMII)
> +		*default_interface = PHY_INTERFACE_MODE_RGMII;

Will this work correctly for 6185? That one has different array,
mv88e6185_phy_interface_modes.

Maybe instead we need to send the default_interface parameter to
chip->info->ops->phylink_get_caps() ?

Marek