It was observed on spider board that with upstream kernel, PHY
auto-negotiation takes almost 1 second longer than with renesas BSP
kernel. This was tracked down to upstream kernel allowing more PHY modes
than renesas BSP kernel.
To avoid that effect when possible, always set max_speed to not more
than phy_interface allows.
While at this, also ensure that etha->speed always gets a supported
value, even if max_speed in device tree is set to something else.
Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
drivers/net/ethernet/renesas/rswitch.c | 48 ++++++++++++++------------
drivers/net/ethernet/renesas/rswitch.h | 1 +
2 files changed, 27 insertions(+), 22 deletions(-)
@@ -1308,37 +1308,41 @@ static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev)staticintrswitch_etha_get_params(structrswitch_device*rdev){-u32max_speed;+structrswitch_etha*etha=rdev->etha;interr;if(!rdev->np_port)return0;/* ignored */-err=of_get_phy_mode(rdev->np_port,&rdev->etha->phy_interface);+err=of_get_phy_mode(rdev->np_port,ða->phy_interface);if(err)returnerr;-err=of_property_read_u32(rdev->np_port,"max-speed",&max_speed);-if(!err){-rdev->etha->speed=max_speed;-return0;-}--/* if no "max-speed" property, let's use default speed */-switch(rdev->etha->phy_interface){-casePHY_INTERFACE_MODE_MII:-rdev->etha->speed=SPEED_100;-break;+switch(etha->phy_interface){casePHY_INTERFACE_MODE_SGMII:-rdev->etha->speed=SPEED_1000;+etha->max_speed=SPEED_1000;break;casePHY_INTERFACE_MODE_USXGMII:-rdev->etha->speed=SPEED_2500;+casePHY_INTERFACE_MODE_5GBASER:+etha->max_speed=SPEED_2500;break;default:return-EINVAL;}+/* Allow max_speed override */+of_property_read_u32(rdev->np_port,"max-speed",ða->max_speed);++/* Set etha->speed to one of values expected by the driver */+if(etha->max_speed<SPEED_100)+return-EINVAL;+elseif(etha->max_speed<SPEED_1000)+etha->speed=SPEED_100;+elseif(etha->max_speed<SPEED_2500)+etha->speed=SPEED_1000;+else+etha->speed=SPEED_2500;+return0;}
From: Andrew Lunn <andrew@lunn.ch> Date: 2025-02-03 18:09:50
On Mon, Feb 03, 2025 at 06:09:41PM +0100, Nikita Yushchenko wrote:
It was observed on spider board that with upstream kernel, PHY
auto-negotiation takes almost 1 second longer than with renesas BSP
kernel. This was tracked down to upstream kernel allowing more PHY modes
than renesas BSP kernel.
To avoid that effect when possible, always set max_speed to not more
than phy_interface allows.
Please could you provide more information about the hardware. Is the
PHY more capable than the MAC?
When you have multi Gigi PHYs, the phy-mode is often taken to be the
starting point. But when the PHY has negotiated a link, it will tell
the MAC what PHY mode it needs to swap to, e.g from SGMII to
2500BaseX, etc.
You should only need max-speed when you have a PHY which can do more
than the MAC.
Also, phylink handles this a lot better than phylib. So you might want
to change rswitch to phylink, especially if you have link speeds > 1G.
Andrew
You should only need max-speed when you have a PHY which can do more
than the MAC.
This is exactly the case.
Unfortunately I don't have the spider schematics nearby, but AFAIU (one of flavours of) the board has
PHYs capable of 5G but connected over SGMII. When two such boards are connected to each other, on
mainline kernel auto-negotiation takes noticeably longer than with the Renesas BSP kernel.
Also, phylink handles this a lot better than phylib. So you might want
to change rswitch to phylink, especially if you have link speeds > 1G.
The reverse switch happened in commit c16a5033f77b ("net: renesas: rswitch: Convert to phy_device").
I did not check the tech details of that, but decided not to touch it.
Nikita
From: Andrew Lunn <andrew@lunn.ch> Date: 2025-02-05 19:28:06
On Wed, Feb 05, 2025 at 05:26:09PM +0100, Nikita Yushchenko wrote:
quoted
You should only need max-speed when you have a PHY which can do more
than the MAC.
This is exactly the case.
O.K. Please expand the commit message to explain this.
Unfortunately I don't have the spider schematics nearby, but AFAIU (one of
flavours of) the board has PHYs capable of 5G but connected over SGMII.
When two such boards are connected to each other, on mainline kernel
auto-negotiation takes noticeably longer than with the Renesas BSP kernel.
I'm actually curious how it established a link at all. If both PHYs
are advertising 5G, they should be happy on the media side. They will
get link. But they will ask the MAC to swap to 5000BaseX or similar. I
assume the MAC cannot do that, but what does it do? How does the PHY
know it should try something slower?
quoted
Also, phylink handles this a lot better than phylib. So you might want
to change rswitch to phylink, especially if you have link speeds > 1G.
The reverse switch happened in commit c16a5033f77b ("net: renesas: rswitch: Convert to phy_device").
I did not check the tech details of that, but decided not to touch it.
Might be worth taking another look, especially if anybody wants to use
SFPs.
Andrew
From: Andrew Lunn <andrew@lunn.ch> Date: 2025-02-05 21:28:26
On Wed, Feb 05, 2025 at 09:26:10PM +0100, Nikita Yushchenko wrote:
quoted
If the interface mode is 5GBASER why set the speed to SPEED_2500?
Also, USXGMII allows up to 10G. So this all looks a bit odd.
2500 is hardware limit (or at least the datasheet states so).
Then it should return -EINVAL if the device tree has a phy-mode the
hardware does not support.
USXGMII is maybe a bit harder, since i don't know if the higher speeds
are optional, but my understanding is that USXGMII allows up to
10G. Is it really using USXGMII, or 2500BaseX?
Andrew