Lines Matching +full:magic +full:- +full:packet
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Broadcom GENET (Gigabit Ethernet) Wake-on-LAN support
5 * Copyright (c) 2014-2025 Broadcom
37 /* ethtool function - get WOL (Wake on LAN) settings, Only Magic Packet
43 struct device *kdev = &priv->pdev->dev; in bcmgenet_get_wol()
46 if (dev->phydev) { in bcmgenet_get_wol()
47 phy_ethtool_get_wol(dev->phydev, wol); in bcmgenet_get_wol()
48 phy_wolopts = wol->wolopts; in bcmgenet_get_wol()
51 /* MAC is not wake-up capable, return what the PHY does */ in bcmgenet_get_wol()
56 wol->supported |= WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER; in bcmgenet_get_wol()
57 wol->wolopts |= priv->wolopts; in bcmgenet_get_wol()
59 /* Return the PHY configured magic password */ in bcmgenet_get_wol()
64 memset(wol->sopass, 0, sizeof(wol->sopass)); in bcmgenet_get_wol()
65 if (wol->wolopts & WAKE_MAGICSECURE) in bcmgenet_get_wol()
66 memcpy(wol->sopass, priv->sopass, sizeof(priv->sopass)); in bcmgenet_get_wol()
69 /* ethtool function - set WOL (Wake on LAN) settings.
70 * Only for magic packet detection mode.
75 struct device *kdev = &priv->pdev->dev; in bcmgenet_set_wol()
78 /* Try Wake-on-LAN from the PHY first */ in bcmgenet_set_wol()
79 if (dev->phydev) { in bcmgenet_set_wol()
80 ret = phy_ethtool_set_wol(dev->phydev, wol); in bcmgenet_set_wol()
81 if (ret != -EOPNOTSUPP && wol->wolopts) in bcmgenet_set_wol()
86 return -ENOTSUPP; in bcmgenet_set_wol()
88 if (wol->wolopts & ~(WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER)) in bcmgenet_set_wol()
89 return -EINVAL; in bcmgenet_set_wol()
91 if (wol->wolopts & WAKE_MAGICSECURE) in bcmgenet_set_wol()
92 memcpy(priv->sopass, wol->sopass, sizeof(priv->sopass)); in bcmgenet_set_wol()
95 if (wol->wolopts) { in bcmgenet_set_wol()
98 if (priv->wol_irq_disabled) { in bcmgenet_set_wol()
99 enable_irq_wake(priv->wol_irq); in bcmgenet_set_wol()
100 enable_irq_wake(priv->irq0); in bcmgenet_set_wol()
102 priv->wol_irq_disabled = false; in bcmgenet_set_wol()
106 if (!priv->wol_irq_disabled) { in bcmgenet_set_wol()
107 disable_irq_wake(priv->wol_irq); in bcmgenet_set_wol()
108 disable_irq_wake(priv->irq0); in bcmgenet_set_wol()
110 priv->wol_irq_disabled = true; in bcmgenet_set_wol()
113 priv->wolopts = wol->wolopts; in bcmgenet_set_wol()
120 struct net_device *dev = priv->dev; in bcmgenet_poll_wol_status()
128 return -ETIMEDOUT; in bcmgenet_poll_wol_status()
138 bcmgenet_umac_writel(priv, get_unaligned_be16(&priv->sopass[0]), in bcmgenet_set_mpd_password()
140 bcmgenet_umac_writel(priv, get_unaligned_be32(&priv->sopass[2]), in bcmgenet_set_mpd_password()
147 struct net_device *dev = priv->dev; in bcmgenet_wol_power_down_cfg()
153 return -EINVAL; in bcmgenet_wol_power_down_cfg()
156 if (priv->wolopts & (WAKE_MAGIC | WAKE_MAGICSECURE)) { in bcmgenet_wol_power_down_cfg()
159 if (priv->wolopts & WAKE_MAGICSECURE) { in bcmgenet_wol_power_down_cfg()
180 netif_dbg(priv, wol, dev, "MPD WOL-ready status set after %d msec\n", in bcmgenet_wol_power_down_cfg()
184 mutex_lock(&dev->phydev->lock); in bcmgenet_wol_power_down_cfg()
185 dev->phydev->state = PHY_READY; in bcmgenet_wol_power_down_cfg()
186 mutex_unlock(&dev->phydev->lock); in bcmgenet_wol_power_down_cfg()
188 clk_prepare_enable(priv->clk_wol); in bcmgenet_wol_power_down_cfg()
191 spin_lock_bh(&priv->reg_lock); in bcmgenet_wol_power_down_cfg()
193 priv->crc_fwd_en = 1; in bcmgenet_wol_power_down_cfg()
203 spin_unlock_bh(&priv->reg_lock); in bcmgenet_wol_power_down_cfg()
217 struct net_device *dev = priv->dev; in bcmgenet_wol_power_up_cfg()
221 netif_err(priv, wol, priv->dev, "invalid mode: %d\n", mode); in bcmgenet_wol_power_up_cfg()
222 return -EINVAL; in bcmgenet_wol_power_up_cfg()
225 clk_disable_unprepare(priv->clk_wol); in bcmgenet_wol_power_up_cfg()
226 priv->crc_fwd_en = 0; in bcmgenet_wol_power_up_cfg()
235 /* Disable Magic Packet Detection */ in bcmgenet_wol_power_up_cfg()
236 if (priv->wolopts & (WAKE_MAGIC | WAKE_MAGICSECURE)) { in bcmgenet_wol_power_up_cfg()
239 return -EPERM; /* already reset so skip the rest */ in bcmgenet_wol_power_up_cfg()
247 return -EPERM; /* already reset so skip the rest */ in bcmgenet_wol_power_up_cfg()
252 spin_lock_bh(&priv->reg_lock); in bcmgenet_wol_power_up_cfg()
256 spin_unlock_bh(&priv->reg_lock); in bcmgenet_wol_power_up_cfg()
259 mutex_lock(&dev->phydev->lock); in bcmgenet_wol_power_up_cfg()
260 if (dev->phydev->link) in bcmgenet_wol_power_up_cfg()
261 dev->phydev->state = PHY_RUNNING; in bcmgenet_wol_power_up_cfg()
263 dev->phydev->state = PHY_NOLINK; in bcmgenet_wol_power_up_cfg()
264 mutex_unlock(&dev->phydev->lock); in bcmgenet_wol_power_up_cfg()