lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E1tKefn-006SMv-Lg@rmk-PC.armlinux.org.uk>
Date: Mon, 09 Dec 2024 14:23:43 +0000
From: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
To: Andrew Lunn <andrew@...n.ch>,
	Heiner Kallweit <hkallweit1@...il.com>
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
	Bryan Whitehead <bryan.whitehead@...rochip.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Marcin Wojtas <marcin.s.wojtas@...il.com>,
	netdev@...r.kernel.org,
	Paolo Abeni <pabeni@...hat.com>,
	UNGLinuxDriver@...rochip.com
Subject: [PATCH net-next 06/10] net: phylink: allow MAC driver to validate eee
 params

Allow the MAC driver to validate EEE parameters before accepting the
set_eee() call.

Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
---
 drivers/net/phy/phylink.c | 16 +++++++++++++++-
 include/linux/phylink.h   | 15 +++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 750356b6a2e9..995bfbbd18e9 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1570,6 +1570,14 @@ static const char *phylink_pause_to_str(int pause)
 	}
 }
 
+static int phylink_validate_tx_lpi(struct phylink *pl, struct ethtool_keee *eee)
+{
+	if (!pl->mac_ops->mac_validate_tx_lpi)
+		return 0;
+
+	return pl->mac_ops->mac_validate_tx_lpi(pl->config, eee);
+}
+
 static void phylink_deactivate_lpi(struct phylink *pl)
 {
 	if (pl->mac_enable_tx_lpi) {
@@ -3170,7 +3178,7 @@ EXPORT_SYMBOL_GPL(phylink_ethtool_get_eee);
 int phylink_ethtool_set_eee(struct phylink *pl, struct ethtool_keee *eee)
 {
 	bool mac_eee = pl->mac_supports_eee;
-	int ret = -EOPNOTSUPP;
+	int ret;
 
 	ASSERT_RTNL();
 
@@ -3187,6 +3195,12 @@ int phylink_ethtool_set_eee(struct phylink *pl, struct ethtool_keee *eee)
 			    eee->tx_lpi_timer);
 	}
 
+	ret = phylink_validate_tx_lpi(pl, eee);
+	if (ret)
+		return ret;
+
+	ret = -EOPNOTSUPP;
+
 	if (pl->phydev) {
 		ret = phy_ethtool_set_eee(pl->phydev, eee);
 		if (ret == 0)
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index f72f0a1feb89..03e790579203 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -187,6 +187,7 @@ void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed);
  * @mac_finish: finish a major reconfiguration of the interface.
  * @mac_link_down: take the link down.
  * @mac_link_up: allow the link to come up.
+ * @mac_validate_tx_lpi: validate LPI configuration.
  * @mac_disable_tx_lpi: disable LPI.
  * @mac_enable_tx_lpi: enable and configure LPI.
  *
@@ -209,6 +210,8 @@ struct phylink_mac_ops {
 			    struct phy_device *phy, unsigned int mode,
 			    phy_interface_t interface, int speed, int duplex,
 			    bool tx_pause, bool rx_pause);
+	int (*mac_validate_tx_lpi)(struct phylink_config *config,
+				   struct ethtool_keee *e);
 	void (*mac_disable_tx_lpi)(struct phylink_config *config);
 	void (*mac_enable_tx_lpi)(struct phylink_config *config, u32 timer,
 				  bool tx_clk_stop);
@@ -407,6 +410,18 @@ void mac_link_up(struct phylink_config *config, struct phy_device *phy,
 		 unsigned int mode, phy_interface_t interface,
 		 int speed, int duplex, bool tx_pause, bool rx_pause);
 
+/**
+ * mac_validate_tx_lpi() - validate the LPI parameters in EEE
+ * @config: a pointer to a &struct phylink_config.
+ * @e: EEE configuration to be validated.
+ *
+ * Validate the LPI configuration parameters in @e, returning an appropriate
+ * error. This will be called prior to any changes being made, and must not
+ * make any changes to existing configuration. Returns zero on success.
+ */
+int (*mac_validate_tx_lpi)(struct phylink_config *config,
+			   struct ethtool_keee *e);
+
 /**
  * mac_disable_tx_lpi() - disable LPI generation at the MAC
  * @config: a pointer to a &struct phylink_config.
-- 
2.30.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ