diff mbox series

[net-next,v4,8/9] net: dsa: dsa_slave_phy_connect(): extend phy's flags with port specific phy flags

Message ID 20210611071527.9333-9-o.rempel@pengutronix.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series provide cable test support for the ksz886x switch | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Oleksij Rempel June 11, 2021, 7:15 a.m. UTC
This patch extends the flags of the phy that's being connected with the
port specific flags of the switch port.

This is needed to handle a port specific erratum of the KSZ8873 switch,
which is added in a later patch.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 net/dsa/slave.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Vladimir Oltean June 11, 2021, 7:24 p.m. UTC | #1
On Fri, Jun 11, 2021 at 09:15:26AM +0200, Oleksij Rempel wrote:
> This patch extends the flags of the phy that's being connected with the
> port specific flags of the switch port.
> 
> This is needed to handle a port specific erratum of the KSZ8873 switch,
> which is added in a later patch.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---

What happens differently between having this patch and not having it?
Florian Fainelli June 11, 2021, 11:26 p.m. UTC | #2
On 6/11/2021 12:24 PM, Vladimir Oltean wrote:
> On Fri, Jun 11, 2021 at 09:15:26AM +0200, Oleksij Rempel wrote:
>> This patch extends the flags of the phy that's being connected with the
>> port specific flags of the switch port.
>>
>> This is needed to handle a port specific erratum of the KSZ8873 switch,
>> which is added in a later patch.
>>
>> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
>> ---
> 
> What happens differently between having this patch and not having it?

The current get_phy_flags() is only processed when we connect to a PHY
via a designed phy-handle property via phylink_of_phy_connect((, but if
we fallback on the internal MDIO bus created by a switch and take the
dsa_slave_phy_connect() path then we would not be processing that flag
and using it at PHY connection time. Oleksij, your proposed patch fails
to check that dsa_switch_ops::get_phy_flags is actually non-NULL, how
about this approach instead where we only fetch the flags once, and we
deal with an option get_phy_flags callback too:

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index d4756b920108..ba7866ec946f 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1749,7 +1749,7 @@ static void dsa_slave_phylink_fixed_state(struct
phylink_config *config,
 }

 /* slave device setup
*******************************************************/
-static int dsa_slave_phy_connect(struct net_device *slave_dev, int addr)
+static int dsa_slave_phy_connect(struct net_device *slave_dev, int
addr, u32 flags)
 {
        struct dsa_port *dp = dsa_slave_to_port(slave_dev);
        struct dsa_switch *ds = dp->ds;
@@ -1760,6 +1760,8 @@ static int dsa_slave_phy_connect(struct net_device
*slave_dev, int addr)
                return -ENODEV;
        }

+       slave_dev->phydev->dev_flags |= flags;
+
        return phylink_connect_phy(dp->pl, slave_dev->phydev);
 }

@@ -1804,7 +1806,7 @@ static int dsa_slave_phy_setup(struct net_device
*slave_dev)
                /* We could not connect to a designated PHY or SFP, so
try to
                 * use the switch internal MDIO bus instead
                 */
-               ret = dsa_slave_phy_connect(slave_dev, dp->index);
+               ret = dsa_slave_phy_connect(slave_dev, dp->index,
phy_flags);
                if (ret) {
                        netdev_err(slave_dev,
                                   "failed to connect to port %d: %d\n",
Oleksij Rempel June 14, 2021, 3:34 a.m. UTC | #3
On Fri, Jun 11, 2021 at 10:24:17PM +0300, Vladimir Oltean wrote:
> On Fri, Jun 11, 2021 at 09:15:26AM +0200, Oleksij Rempel wrote:
> > This patch extends the flags of the phy that's being connected with the
> > port specific flags of the switch port.
> > 
> > This is needed to handle a port specific erratum of the KSZ8873 switch,
> > which is added in a later patch.
> > 
> > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > ---
> 
> What happens differently between having this patch and not having it?

Without this patch, the PHY driver will not get the phyflag provided by the
DSA driver.

Regards,
Oleksij
Oleksij Rempel June 14, 2021, 3:37 a.m. UTC | #4
On Fri, Jun 11, 2021 at 04:26:33PM -0700, Florian Fainelli wrote:
> 
> 
> On 6/11/2021 12:24 PM, Vladimir Oltean wrote:
> > On Fri, Jun 11, 2021 at 09:15:26AM +0200, Oleksij Rempel wrote:
> >> This patch extends the flags of the phy that's being connected with the
> >> port specific flags of the switch port.
> >>
> >> This is needed to handle a port specific erratum of the KSZ8873 switch,
> >> which is added in a later patch.
> >>
> >> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> >> ---
> > 
> > What happens differently between having this patch and not having it?
> 
> The current get_phy_flags() is only processed when we connect to a PHY
> via a designed phy-handle property via phylink_of_phy_connect((, but if
> we fallback on the internal MDIO bus created by a switch and take the
> dsa_slave_phy_connect() path then we would not be processing that flag
> and using it at PHY connection time. Oleksij, your proposed patch fails
> to check that dsa_switch_ops::get_phy_flags is actually non-NULL, how
> about this approach instead where we only fetch the flags once, and we
> deal with an option get_phy_flags callback too:

ok, sounds good.
Thank you.

> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index d4756b920108..ba7866ec946f 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1749,7 +1749,7 @@ static void dsa_slave_phylink_fixed_state(struct
> phylink_config *config,
>  }
> 
>  /* slave device setup
> *******************************************************/
> -static int dsa_slave_phy_connect(struct net_device *slave_dev, int addr)
> +static int dsa_slave_phy_connect(struct net_device *slave_dev, int
> addr, u32 flags)
>  {
>         struct dsa_port *dp = dsa_slave_to_port(slave_dev);
>         struct dsa_switch *ds = dp->ds;
> @@ -1760,6 +1760,8 @@ static int dsa_slave_phy_connect(struct net_device
> *slave_dev, int addr)
>                 return -ENODEV;
>         }
> 
> +       slave_dev->phydev->dev_flags |= flags;
> +
>         return phylink_connect_phy(dp->pl, slave_dev->phydev);
>  }
> 
> @@ -1804,7 +1806,7 @@ static int dsa_slave_phy_setup(struct net_device
> *slave_dev)
>                 /* We could not connect to a designated PHY or SFP, so
> try to
>                  * use the switch internal MDIO bus instead
>                  */
> -               ret = dsa_slave_phy_connect(slave_dev, dp->index);
> +               ret = dsa_slave_phy_connect(slave_dev, dp->index,
> phy_flags);
>                 if (ret) {
>                         netdev_err(slave_dev,
>                                    "failed to connect to port %d: %d\n",
> -- 
> Florian
> 
>
diff mbox series

Patch

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index d4756b920108..ca344b37d02d 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1760,6 +1760,10 @@  static int dsa_slave_phy_connect(struct net_device *slave_dev, int addr)
 		return -ENODEV;
 	}
 
+	if (ds->ops->get_phy_flags)
+		slave_dev->phydev->dev_flags |=
+			ds->ops->get_phy_flags(ds, dp->index);
+
 	return phylink_connect_phy(dp->pl, slave_dev->phydev);
 }