[PATCH net 3/3] net: lan743x: Address problems with wake option flags configuration sequences

From: Raju Lakkaraju
Date: Mon Feb 26 2024 - 03:12:14 EST


Wake options handling has been reworked as follows:
a. We only enable secure on magic packet when both secure and magic wol
options are requested together.
b. If secure-on magic packet had been previously enabled, and a subsequent
command does not include it, we add it. This was done to workaround a
problem with the 'pm-suspend' application which is unaware of secure-on
magic packet being enabled and can unintentionally disable it prior to
putting the system into suspend.

Fixes: 6b3768ac8e2b3 ("net: lan743x: Add support to Secure-ON WOL")
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@xxxxxxxxxxxxx>
---
drivers/net/ethernet/microchip/lan743x_ethtool.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c b/drivers/net/ethernet/microchip/lan743x_ethtool.c
index 4899582b3d1d..cda4df2ac1cd 100644
--- a/drivers/net/ethernet/microchip/lan743x_ethtool.c
+++ b/drivers/net/ethernet/microchip/lan743x_ethtool.c
@@ -1165,6 +1165,16 @@ static int lan743x_ethtool_set_wol(struct net_device *netdev,
struct lan743x_adapter *adapter = netdev_priv(netdev);
int ret;

+ if (wol->wolopts && wol->wolopts != adapter->wolopts &&
+ adapter->wolopts & WAKE_MAGICSECURE) {
+ wol->wolopts |= WAKE_MAGICSECURE;
+ netif_warn(adapter, drv, adapter->netdev,
+ "Ensure secure-on magic packet remains enabled if not explicitly disabled\n");
+ }
+
+ if ((wol->wolopts & WAKE_MAGICSECURE) && !(wol->wolopts & WAKE_MAGIC))
+ return -EINVAL;
+
if (netdev->phydev) {
ret = phy_ethtool_set_wol(netdev->phydev, wol);
if (ret != -EOPNOTSUPP && ret != 0)
--
2.34.1