diff mbox series

[v4,net-next,5/9] net: phy: Keep track of EEE configuration

Message ID 20230618184119.4017149-6-andrew@lunn.ch (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: Rework EEE | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 408 this patch: 408
netdev/cc_maintainers warning 4 maintainers not CCed: kuba@kernel.org davem@davemloft.net pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 287 this patch: 287
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 394 this patch: 394
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
netdev/kdoc fail Errors and warnings before: 0 this patch: 1
netdev/source_inline success Was 0 now: 0

Commit Message

Andrew Lunn June 18, 2023, 6:41 p.m. UTC
Have phylib keep track of the EEE configuration. This simplifies the
MAC drivers, in that they don't need to store it.

Future patches to phylib will also make use of this information to
further simplify the MAC drivers.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c | 5 ++++-
 include/linux/phy.h   | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Russell King (Oracle) June 18, 2023, 7:20 p.m. UTC | #1
On Sun, Jun 18, 2023 at 08:41:15PM +0200, Andrew Lunn wrote:
> Have phylib keep track of the EEE configuration. This simplifies the
> MAC drivers, in that they don't need to store it.
> 
> Future patches to phylib will also make use of this information to
> further simplify the MAC drivers.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  drivers/net/phy/phy.c | 5 ++++-
>  include/linux/phy.h   | 3 +++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 629499e5aff0..48150d5626d8 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1588,7 +1588,7 @@ EXPORT_SYMBOL(phy_get_eee_err);
>   * @data: ethtool_eee data
>   *
>   * Description: it reportes the Supported/Advertisement/LP Advertisement
> - * capabilities.
> + * capabilities, etc.

Any scope to drop the "it" and fix "reports" ?

Apart from that, looks good.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Thanks!
Simon Horman June 19, 2023, 2:20 p.m. UTC | #2
On Sun, Jun 18, 2023 at 08:41:15PM +0200, Andrew Lunn wrote:
> Have phylib keep track of the EEE configuration. This simplifies the
> MAC drivers, in that they don't need to store it.
> 
> Future patches to phylib will also make use of this information to
> further simplify the MAC drivers.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

...

> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 66f69d512f45..473ddf62bee9 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -30,6 +30,7 @@
>  #include <linux/refcount.h>
>  
>  #include <linux/atomic.h>
> +#include <net/eee.h>
>  
>  #define PHY_DEFAULT_FEATURES	(SUPPORTED_Autoneg | \
>  				 SUPPORTED_TP | \
> @@ -585,6 +586,7 @@ struct macsec_ops;
>   * @advertising_eee: Currently advertised EEE linkmodes
>   * @eee_enabled: Flag indicating whether the EEE feature is enabled
>   * @enable_tx_lpi: When True, MAC should transmit LPI to PHY
> + * eee_cfg: User configuration of EEE

Hi Andrew,

a minor nit from my side: eee_cfg: -> @eee_cfg:

>   * @lp_advertising: Current link partner advertised linkmodes
>   * @host_interfaces: PHY interface modes supported by host
>   * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited
> @@ -702,6 +704,7 @@ struct phy_device {
>  	/* Energy efficient ethernet modes which should be prohibited */
>  	u32 eee_broken_modes;
>  	bool enable_tx_lpi;
> +	struct eee_config eee_cfg;
>  
>  #ifdef CONFIG_LED_TRIGGER_PHY
>  	struct phy_led_trigger *phy_led_triggers;
> -- 
> 2.40.1
> 
>
Florian Fainelli June 19, 2023, 3:27 p.m. UTC | #3
On 6/18/2023 7:41 PM, Andrew Lunn wrote:
> Have phylib keep track of the EEE configuration. This simplifies the
> MAC drivers, in that they don't need to store it.
> 
> Future patches to phylib will also make use of this information to
> further simplify the MAC drivers.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

With both Simon's and Russell's feedback addressed:

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 629499e5aff0..48150d5626d8 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1588,7 +1588,7 @@  EXPORT_SYMBOL(phy_get_eee_err);
  * @data: ethtool_eee data
  *
  * Description: it reportes the Supported/Advertisement/LP Advertisement
- * capabilities.
+ * capabilities, etc.
  */
 int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
 {
@@ -1599,6 +1599,7 @@  int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
 
 	mutex_lock(&phydev->lock);
 	ret = genphy_c45_ethtool_get_eee(phydev, data);
+	eeecfg_to_eee(&phydev->eee_cfg, data);
 	mutex_unlock(&phydev->lock);
 
 	return ret;
@@ -1621,6 +1622,8 @@  int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
 
 	mutex_lock(&phydev->lock);
 	ret = genphy_c45_ethtool_set_eee(phydev, data);
+	if (!ret)
+		eee_to_eeecfg(data, &phydev->eee_cfg);
 	mutex_unlock(&phydev->lock);
 
 	return ret;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 66f69d512f45..473ddf62bee9 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -30,6 +30,7 @@ 
 #include <linux/refcount.h>
 
 #include <linux/atomic.h>
+#include <net/eee.h>
 
 #define PHY_DEFAULT_FEATURES	(SUPPORTED_Autoneg | \
 				 SUPPORTED_TP | \
@@ -585,6 +586,7 @@  struct macsec_ops;
  * @advertising_eee: Currently advertised EEE linkmodes
  * @eee_enabled: Flag indicating whether the EEE feature is enabled
  * @enable_tx_lpi: When True, MAC should transmit LPI to PHY
+ * eee_cfg: User configuration of EEE
  * @lp_advertising: Current link partner advertised linkmodes
  * @host_interfaces: PHY interface modes supported by host
  * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited
@@ -702,6 +704,7 @@  struct phy_device {
 	/* Energy efficient ethernet modes which should be prohibited */
 	u32 eee_broken_modes;
 	bool enable_tx_lpi;
+	struct eee_config eee_cfg;
 
 #ifdef CONFIG_LED_TRIGGER_PHY
 	struct phy_led_trigger *phy_led_triggers;