Message ID | 20240221062107.778661-8-o.rempel@pengutronix.de (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: ethernet: Rework EEE | expand |
> -----Original Message----- > From: Oleksij Rempel <o.rempel@pengutronix.de> > Sent: 2024年2月21日 14:21 > To: Wei Fang <wei.fang@nxp.com>; David S. Miller <davem@davemloft.net>; > Eric Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; > Paolo Abeni <pabeni@redhat.com>; Andrew Lunn <andrew@lunn.ch>; > Heiner Kallweit <hkallweit1@gmail.com>; Russell King > <linux@armlinux.org.uk> > Cc: Oleksij Rempel <o.rempel@pengutronix.de>; kernel@pengutronix.de; > linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Shenwei Wang > <shenwei.wang@nxp.com>; Clark Wang <xiaoning.wang@nxp.com>; > dl-linux-imx <linux-imx@nxp.com> > Subject: [PATCH net-next v5 7/8] net: fec: Move fec_enet_eee_mode_set() > and helper earlier > > From: Andrew Lunn <andrew@lunn.ch> > > FEC is about to get its EEE code re-written. To allow this, move > fec_enet_eee_mode_set() before fec_enet_adjust_link() which will need to > call it. > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > --- > drivers/net/ethernet/freescale/fec_main.c | 75 ++++++++++++----------- > 1 file changed, 38 insertions(+), 37 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/fec_main.c > b/drivers/net/ethernet/freescale/fec_main.c > index 207f1f66c117..a2c786550342 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -2017,6 +2017,44 @@ static int fec_get_mac(struct net_device *ndev) > /* > * Phy section > */ > + > +/* LPI Sleep Ts count base on tx clk (clk_ref). > + * The lpi sleep cnt value = X us / (cycle_ns). > + */ > +static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) { > + struct fec_enet_private *fep = netdev_priv(ndev); > + > + return us * (fep->clk_ref_rate / 1000) / 1000; } > + > +static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) > +{ > + struct fec_enet_private *fep = netdev_priv(ndev); > + struct ethtool_keee *p = &fep->eee; > + unsigned int sleep_cycle, wake_cycle; > + int ret = 0; > + > + if (enable) { > + ret = phy_init_eee(ndev->phydev, false); > + if (ret) > + return ret; > + > + sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); > + wake_cycle = sleep_cycle; > + } else { > + sleep_cycle = 0; > + wake_cycle = 0; > + } > + > + p->tx_lpi_enabled = enable; > + > + writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); > + writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); > + > + return 0; > +} > + > static void fec_enet_adjust_link(struct net_device *ndev) { > struct fec_enet_private *fep = netdev_priv(ndev); @@ -3121,43 +3159,6 > @@ static int fec_enet_set_coalesce(struct net_device *ndev, > return 0; > } > > -/* LPI Sleep Ts count base on tx clk (clk_ref). > - * The lpi sleep cnt value = X us / (cycle_ns). > - */ > -static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) -{ > - struct fec_enet_private *fep = netdev_priv(ndev); > - > - return us * (fep->clk_ref_rate / 1000) / 1000; > -} > - > -static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) -{ > - struct fec_enet_private *fep = netdev_priv(ndev); > - struct ethtool_keee *p = &fep->eee; > - unsigned int sleep_cycle, wake_cycle; > - int ret = 0; > - > - if (enable) { > - ret = phy_init_eee(ndev->phydev, false); > - if (ret) > - return ret; > - > - sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); > - wake_cycle = sleep_cycle; > - } else { > - sleep_cycle = 0; > - wake_cycle = 0; > - } > - > - p->tx_lpi_enabled = enable; > - > - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); > - writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); > - > - return 0; > -} > - > static int > fec_enet_get_eee(struct net_device *ndev, struct ethtool_keee *edata) { > -- > 2.39.2 Reviewed-by: Wei Fang <wei.fang@nxp.com>
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 207f1f66c117..a2c786550342 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2017,6 +2017,44 @@ static int fec_get_mac(struct net_device *ndev) /* * Phy section */ + +/* LPI Sleep Ts count base on tx clk (clk_ref). + * The lpi sleep cnt value = X us / (cycle_ns). + */ +static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + + return us * (fep->clk_ref_rate / 1000) / 1000; +} + +static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + struct ethtool_keee *p = &fep->eee; + unsigned int sleep_cycle, wake_cycle; + int ret = 0; + + if (enable) { + ret = phy_init_eee(ndev->phydev, false); + if (ret) + return ret; + + sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); + wake_cycle = sleep_cycle; + } else { + sleep_cycle = 0; + wake_cycle = 0; + } + + p->tx_lpi_enabled = enable; + + writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); + writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); + + return 0; +} + static void fec_enet_adjust_link(struct net_device *ndev) { struct fec_enet_private *fep = netdev_priv(ndev); @@ -3121,43 +3159,6 @@ static int fec_enet_set_coalesce(struct net_device *ndev, return 0; } -/* LPI Sleep Ts count base on tx clk (clk_ref). - * The lpi sleep cnt value = X us / (cycle_ns). - */ -static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - - return us * (fep->clk_ref_rate / 1000) / 1000; -} - -static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - struct ethtool_keee *p = &fep->eee; - unsigned int sleep_cycle, wake_cycle; - int ret = 0; - - if (enable) { - ret = phy_init_eee(ndev->phydev, false); - if (ret) - return ret; - - sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); - wake_cycle = sleep_cycle; - } else { - sleep_cycle = 0; - wake_cycle = 0; - } - - p->tx_lpi_enabled = enable; - - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); - writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); - - return 0; -} - static int fec_enet_get_eee(struct net_device *ndev, struct ethtool_keee *edata) {