* [PATCH net-next 0/3] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY
@ 2022-12-26 7:14 Yoshihiro Shimoda
2022-12-26 7:14 ` [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY Yoshihiro Shimoda
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2022-12-26 7:14 UTC (permalink / raw)
To: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni
Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda
The patch [1/3] sets phydev->host_interfaces by phylink for Marvell PHY
driver (marvell10g) to initialize the MACTYPE.
The patch [2/3] siplifies the rswitch driver, and [3/3] adds
phy_power_on() calling to initialize the Ethernet SERDES PHY driver
(r8a779f0-eth-serdes) for each channel.
Yoshihiro Shimoda (3):
net: phylink: Set host_interfaces for a non-sfp PHY
net: ethernet: renesas: rswitch: Simplify struct phy * handling
net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling
drivers/net/ethernet/renesas/rswitch.c | 48 ++++++++++++++------------
drivers/net/ethernet/renesas/rswitch.h | 1 +
drivers/net/phy/phylink.c | 1 +
3 files changed, 28 insertions(+), 22 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY 2022-12-26 7:14 [PATCH net-next 0/3] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY Yoshihiro Shimoda @ 2022-12-26 7:14 ` Yoshihiro Shimoda 2023-01-03 9:54 ` Russell King (Oracle) 2022-12-26 7:14 ` [PATCH net-next 2/3] net: ethernet: renesas: rswitch: Simplify struct phy * handling Yoshihiro Shimoda 2022-12-26 7:14 ` [PATCH net-next 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Yoshihiro Shimoda 2 siblings, 1 reply; 8+ messages in thread From: Yoshihiro Shimoda @ 2022-12-26 7:14 UTC (permalink / raw) To: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda Set phy_dev->host_interfaces by pl->link_interface in phylink_fwnode_phy_connect() for a non-sfp PHY. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas•com> --- drivers/net/phy/phylink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 09cc65c0da93..1958d6cc9ef9 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1809,6 +1809,7 @@ int phylink_fwnode_phy_connect(struct phylink *pl, pl->link_interface = phy_dev->interface; pl->link_config.interface = pl->link_interface; } + __set_bit(pl->link_interface, phy_dev->host_interfaces); ret = phy_attach_direct(pl->netdev, phy_dev, flags, pl->link_interface); -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY 2022-12-26 7:14 ` [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY Yoshihiro Shimoda @ 2023-01-03 9:54 ` Russell King (Oracle) 2023-01-05 8:00 ` Yoshihiro Shimoda 0 siblings, 1 reply; 8+ messages in thread From: Russell King (Oracle) @ 2023-01-03 9:54 UTC (permalink / raw) To: Yoshihiro Shimoda Cc: andrew, hkallweit1, davem, edumazet, kuba, pabeni, netdev, linux-renesas-soc On Mon, Dec 26, 2022 at 04:14:23PM +0900, Yoshihiro Shimoda wrote: > Set phy_dev->host_interfaces by pl->link_interface in > phylink_fwnode_phy_connect() for a non-sfp PHY. > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas•com> > --- > drivers/net/phy/phylink.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 09cc65c0da93..1958d6cc9ef9 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c > @@ -1809,6 +1809,7 @@ int phylink_fwnode_phy_connect(struct phylink *pl, > pl->link_interface = phy_dev->interface; > pl->link_config.interface = pl->link_interface; > } > + __set_bit(pl->link_interface, phy_dev->host_interfaces); This is probably going to break Macchiatobin platforms, since we declare that the link mode there is 10GBASE-R, we'll end up with host_interfaces containing just this mode. This will cause the 88x3310 driver to select a rate matching interface mode, which the mvpp2 MAC can't support. If we want to fill host_interfaces in, then it needs to be filled in properly - and by that I mean with all the host interface modes that can be electrically supported - otherwise platforms will break. So, sorry, but NAK on this change. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY 2023-01-03 9:54 ` Russell King (Oracle) @ 2023-01-05 8:00 ` Yoshihiro Shimoda 0 siblings, 0 replies; 8+ messages in thread From: Yoshihiro Shimoda @ 2023-01-05 8:00 UTC (permalink / raw) To: Russell King Cc: andrew@lunn•ch, hkallweit1@gmail•com, davem@davemloft•net, edumazet@google•com, kuba@kernel•org, pabeni@redhat•com, netdev@vger•kernel.org, linux-renesas-soc@vger•kernel.org Hello Russell, > From: Russell King, Sent: Tuesday, January 3, 2023 6:54 PM > > On Mon, Dec 26, 2022 at 04:14:23PM +0900, Yoshihiro Shimoda wrote: > > Set phy_dev->host_interfaces by pl->link_interface in > > phylink_fwnode_phy_connect() for a non-sfp PHY. > > > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas•com> > > --- > > drivers/net/phy/phylink.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > > index 09cc65c0da93..1958d6cc9ef9 100644 > > --- a/drivers/net/phy/phylink.c > > +++ b/drivers/net/phy/phylink.c > > @@ -1809,6 +1809,7 @@ int phylink_fwnode_phy_connect(struct phylink *pl, > > pl->link_interface = phy_dev->interface; > > pl->link_config.interface = pl->link_interface; > > } > > + __set_bit(pl->link_interface, phy_dev->host_interfaces); > > This is probably going to break Macchiatobin platforms, since we > declare that the link mode there is 10GBASE-R, we'll end up with > host_interfaces containing just this mode. This will cause the > 88x3310 driver to select a rate matching interface mode, which the > mvpp2 MAC can't support. > > If we want to fill host_interfaces in, then it needs to be filled in > properly - and by that I mean with all the host interface modes that > can be electrically supported - otherwise platforms will break. > > So, sorry, but NAK on this change. Thank you for your review! I understood why NAK on this change: --- static int mv3310_select_mactype(unsigned long *interfaces) { ... else if (test_bit(PHY_INTERFACE_MODE_SGMII, interfaces) && test_bit(PHY_INTERFACE_MODE_10GBASER, interfaces)) return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER; ... else if (test_bit(PHY_INTERFACE_MODE_10GBASER, interfaces)) return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH; ... --- - On this change, since the interfaces is set to PHY_INTERFACE_MODE_10GBASER only, this function will return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH. - Without this change, since the host_interfaces value is zero, the mv3310_select_mactype() will not called. I'll investigate phylink and marvell10 codes again. Best regards, Yoshihiro Shimoda ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 2/3] net: ethernet: renesas: rswitch: Simplify struct phy * handling 2022-12-26 7:14 [PATCH net-next 0/3] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY Yoshihiro Shimoda 2022-12-26 7:14 ` [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY Yoshihiro Shimoda @ 2022-12-26 7:14 ` Yoshihiro Shimoda 2022-12-26 7:14 ` [PATCH net-next 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Yoshihiro Shimoda 2 siblings, 0 replies; 8+ messages in thread From: Yoshihiro Shimoda @ 2022-12-26 7:14 UTC (permalink / raw) To: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda Simplify struct phy *serdes handling by keeping the valiable in the struct rswitch_device. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas•com> --- drivers/net/ethernet/renesas/rswitch.c | 40 ++++++++++++-------------- drivers/net/ethernet/renesas/rswitch.h | 1 + 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 6441892636db..ca79ee168206 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1235,49 +1235,40 @@ static void rswitch_phylink_deinit(struct rswitch_device *rdev) phylink_destroy(rdev->phylink); } -static int rswitch_serdes_set_params(struct rswitch_device *rdev) +static int rswitch_serdes_phy_get(struct rswitch_device *rdev) { struct device_node *port = rswitch_get_port_node(rdev); struct phy *serdes; - int err; serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); of_node_put(port); if (IS_ERR(serdes)) return PTR_ERR(serdes); + rdev->serdes = serdes; + + return 0; +} + +static int rswitch_serdes_set_params(struct rswitch_device *rdev) +{ + int err; - err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET, + err = phy_set_mode_ext(rdev->serdes, PHY_MODE_ETHERNET, rdev->etha->phy_interface); if (err < 0) return err; - return phy_set_speed(serdes, rdev->etha->speed); + return phy_set_speed(rdev->serdes, rdev->etha->speed); } static int rswitch_serdes_init(struct rswitch_device *rdev) { - struct device_node *port = rswitch_get_port_node(rdev); - struct phy *serdes; - - serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); - of_node_put(port); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); - - return phy_init(serdes); + return phy_init(rdev->serdes); } static int rswitch_serdes_deinit(struct rswitch_device *rdev) { - struct device_node *port = rswitch_get_port_node(rdev); - struct phy *serdes; - - serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); - of_node_put(port); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); - - return phy_exit(serdes); + return phy_exit(rdev->serdes); } static int rswitch_ether_port_init_one(struct rswitch_device *rdev) @@ -1299,6 +1290,10 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev) if (err < 0) goto err_phylink_init; + err = rswitch_serdes_phy_get(rdev); + if (err < 0) + goto err_serdes_phy_get; + err = rswitch_serdes_set_params(rdev); if (err < 0) goto err_serdes_set_params; @@ -1306,6 +1301,7 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev) return 0; err_serdes_set_params: +err_serdes_phy_get: rswitch_phylink_deinit(rdev); err_phylink_init: diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h index edbdd1b98d3d..d9a0be6666f5 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -941,6 +941,7 @@ struct rswitch_device { int port; struct rswitch_etha *etha; + struct phy *serdes; }; struct rswitch_mfwd_mac_table_entry { -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling 2022-12-26 7:14 [PATCH net-next 0/3] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY Yoshihiro Shimoda 2022-12-26 7:14 ` [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY Yoshihiro Shimoda 2022-12-26 7:14 ` [PATCH net-next 2/3] net: ethernet: renesas: rswitch: Simplify struct phy * handling Yoshihiro Shimoda @ 2022-12-26 7:14 ` Yoshihiro Shimoda 2023-01-03 9:56 ` Russell King (Oracle) 2 siblings, 1 reply; 8+ messages in thread From: Yoshihiro Shimoda @ 2022-12-26 7:14 UTC (permalink / raw) To: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda Some Ethernet PHYs (like marvell10g) will decide the host interface mode by the media-side speed. So, the rswitch driver needs to initialize one of the Ethernet SERDES (r8a779f0-eth-serdes) ports after linked the Ethernet PHY up. The r8a779f0-eth-serdes driver has .init() for initializing all ports and .power_on() for initializing each port. So, add phy_power_{on,off} calling for it. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas•com> --- drivers/net/ethernet/renesas/rswitch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index ca79ee168206..2f335c95f5a8 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1180,6 +1180,10 @@ static void rswitch_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface) { + struct net_device *ndev = to_net_dev(config->dev); + struct rswitch_device *rdev = netdev_priv(ndev); + + phy_power_off(rdev->serdes); } static void rswitch_mac_link_up(struct phylink_config *config, @@ -1187,7 +1191,11 @@ static void rswitch_mac_link_up(struct phylink_config *config, phy_interface_t interface, int speed, int duplex, bool tx_pause, bool rx_pause) { + struct net_device *ndev = to_net_dev(config->dev); + struct rswitch_device *rdev = netdev_priv(ndev); + /* Current hardware cannot change speed at runtime */ + phy_power_on(rdev->serdes); } static const struct phylink_mac_ops rswitch_phylink_ops = { -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling 2022-12-26 7:14 ` [PATCH net-next 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Yoshihiro Shimoda @ 2023-01-03 9:56 ` Russell King (Oracle) 2023-01-06 7:34 ` Yoshihiro Shimoda 0 siblings, 1 reply; 8+ messages in thread From: Russell King (Oracle) @ 2023-01-03 9:56 UTC (permalink / raw) To: Yoshihiro Shimoda Cc: andrew, hkallweit1, davem, edumazet, kuba, pabeni, netdev, linux-renesas-soc On Mon, Dec 26, 2022 at 04:14:25PM +0900, Yoshihiro Shimoda wrote: > Some Ethernet PHYs (like marvell10g) will decide the host interface > mode by the media-side speed. So, the rswitch driver needs to > initialize one of the Ethernet SERDES (r8a779f0-eth-serdes) ports > after linked the Ethernet PHY up. The r8a779f0-eth-serdes driver has > .init() for initializing all ports and .power_on() for initializing > each port. So, add phy_power_{on,off} calling for it. > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas•com> > --- > drivers/net/ethernet/renesas/rswitch.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c > index ca79ee168206..2f335c95f5a8 100644 > --- a/drivers/net/ethernet/renesas/rswitch.c > +++ b/drivers/net/ethernet/renesas/rswitch.c > @@ -1180,6 +1180,10 @@ static void rswitch_mac_link_down(struct phylink_config *config, > unsigned int mode, > phy_interface_t interface) > { > + struct net_device *ndev = to_net_dev(config->dev); > + struct rswitch_device *rdev = netdev_priv(ndev); > + > + phy_power_off(rdev->serdes); > } > > static void rswitch_mac_link_up(struct phylink_config *config, > @@ -1187,7 +1191,11 @@ static void rswitch_mac_link_up(struct phylink_config *config, > phy_interface_t interface, int speed, > int duplex, bool tx_pause, bool rx_pause) > { > + struct net_device *ndev = to_net_dev(config->dev); > + struct rswitch_device *rdev = netdev_priv(ndev); > + > /* Current hardware cannot change speed at runtime */ > + phy_power_on(rdev->serdes); > } > > static const struct phylink_mac_ops rswitch_phylink_ops = { This looks to me like it will break anyone using an in-band link, where the link status comes from the PCS behind the series that you're now powering down and up. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH net-next 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling 2023-01-03 9:56 ` Russell King (Oracle) @ 2023-01-06 7:34 ` Yoshihiro Shimoda 0 siblings, 0 replies; 8+ messages in thread From: Yoshihiro Shimoda @ 2023-01-06 7:34 UTC (permalink / raw) To: Russell King Cc: andrew@lunn•ch, hkallweit1@gmail•com, davem@davemloft•net, edumazet@google•com, kuba@kernel•org, pabeni@redhat•com, netdev@vger•kernel.org, linux-renesas-soc@vger•kernel.org Hello Russell, > From: Russell King, Sent: Tuesday, January 3, 2023 6:56 PM > > On Mon, Dec 26, 2022 at 04:14:25PM +0900, Yoshihiro Shimoda wrote: > > Some Ethernet PHYs (like marvell10g) will decide the host interface > > mode by the media-side speed. So, the rswitch driver needs to > > initialize one of the Ethernet SERDES (r8a779f0-eth-serdes) ports > > after linked the Ethernet PHY up. The r8a779f0-eth-serdes driver has > > .init() for initializing all ports and .power_on() for initializing > > each port. So, add phy_power_{on,off} calling for it. > > > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas•com> > > --- > > drivers/net/ethernet/renesas/rswitch.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c > > index ca79ee168206..2f335c95f5a8 100644 > > --- a/drivers/net/ethernet/renesas/rswitch.c > > +++ b/drivers/net/ethernet/renesas/rswitch.c > > @@ -1180,6 +1180,10 @@ static void rswitch_mac_link_down(struct phylink_config *config, > > unsigned int mode, > > phy_interface_t interface) > > { > > + struct net_device *ndev = to_net_dev(config->dev); > > + struct rswitch_device *rdev = netdev_priv(ndev); > > + > > + phy_power_off(rdev->serdes); > > } > > > > static void rswitch_mac_link_up(struct phylink_config *config, > > @@ -1187,7 +1191,11 @@ static void rswitch_mac_link_up(struct phylink_config *config, > > phy_interface_t interface, int speed, > > int duplex, bool tx_pause, bool rx_pause) > > { > > + struct net_device *ndev = to_net_dev(config->dev); > > + struct rswitch_device *rdev = netdev_priv(ndev); > > + > > /* Current hardware cannot change speed at runtime */ > > + phy_power_on(rdev->serdes); > > } > > > > static const struct phylink_mac_ops rswitch_phylink_ops = { > > This looks to me like it will break anyone using an in-band link, > where the link status comes from the PCS behind the series that > you're now powering down and up. Thank you for your review! To be honest, I didn't know about "an in-band link". So, I studied a little, and then I might understand about your comments. However, I still don't understand whether this hardware (rswitch) can support the "in-band link" or not. This seems to need a special hardware feature for "in-band link" and only software cannot support it, IIUC. # Unfortunately, this hardware's datasheet cannot be in public for now though... Anyway, I'll add a condition which this driver cannot support MLO_AN_INBAND to avoid a problem by someone for now. Best regards, Yoshihiro Shimoda ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-01-06 7:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-26 7:14 [PATCH net-next 0/3] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY Yoshihiro Shimoda
2022-12-26 7:14 ` [PATCH net-next 1/3] net: phylink: Set host_interfaces for a non-sfp PHY Yoshihiro Shimoda
2023-01-03 9:54 ` Russell King (Oracle)
2023-01-05 8:00 ` Yoshihiro Shimoda
2022-12-26 7:14 ` [PATCH net-next 2/3] net: ethernet: renesas: rswitch: Simplify struct phy * handling Yoshihiro Shimoda
2022-12-26 7:14 ` [PATCH net-next 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Yoshihiro Shimoda
2023-01-03 9:56 ` Russell King (Oracle)
2023-01-06 7:34 ` Yoshihiro Shimoda
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox