net: phy: smsc: add WoL support to LAN8740/LAN8742 PHYs
Subsystems (4)
PATCH v2 1/1 net: phy: smsc: add WoL support to LAN8740/LAN8742 PHYs
From: Tristram Ha <[email protected]>
Microchip LAN8740/LAN8742 PHYs support basic unicast, broadcast, and Magic Packet WoL. They have one pattern filter matching up to 128 bytes of frame data, which can be used to implement ARP or multicast WoL.
ARP WoL matches ARP request for IPv4 address of the net device using the PHY.
Multicast WoL matches IPv6 Neighbor Solicitation which is sent when somebody wants to talk to the net device using IPv6. This implementation may not be appropriate and can be changed by users later.
---
v2
- use in_dev_put() only when IP support is enabled
v1
- use in_dev_get() to retrieve IP address to avoid compiler warning
- use ipv6_get_lladdr() to retrieve IPv6 address
- use that function only when IPv6 support is enabled
- export that function in addrconf.c
- program the MAC address in a loop
- always set datalen in lan874x_chk_wol_pattern()
- add spaces around "<<"
- select CRC16 in Kconfig as crc16() is used in driver
drivers/net/phy/Kconfig | 1 + drivers/net/phy/smsc.c | 303 +++++++++++++++++++++++++++++++++++++++- include/linux/smscphy.h | 34 +++++ net/ipv6/addrconf.c | 1 + 4 files changed, 337 insertions(+), 2 deletions(-)
drivers/net/phy/Kconfig +1 -0
@@ -344,6 +344,7 @@ config ROCKCHIP_PHY config SMSC_PHY tristate "SMSC PHYs" + select CRC16 help Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
drivers/net/phy/smsc.c +301 -2
345 lines not on this page · raw message
include/linux/smscphy.h +34 -0
@@ -38,4 +38,38 @@ int smsc_phy_set_tunable(struct phy_device *phydev, struct ethtool_tunable *tuna, const void *data);int smsc_phy_probe (struct phy_device *phydev); +#define MII_LAN874X_PHY_MMD_WOL_WUCSR 0x8010 +#define MII_LAN874X_PHY_MMD_WOL_WUF_CFGA 0x8011 +#define MII_LAN874X_PHY_MMD_WOL_WUF_CFGB 0x8012 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK0 0x8021 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK1 0x8022 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK2 0x8023 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK3 0x8024 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK4 0x8025 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK5 0x8026 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK6 0x8027 +#define MII_LAN874X_PHY_MMD_WOL_WUF_MASK7 0x8028 +#define MII_LAN874X_PHY_MMD_WOL_RX_ADDRA 0x8061 +#define MII_LAN874X_PHY_MMD_WOL_RX_ADDRB 0x8062 +#define MII_LAN874X_PHY_MMD_WOL_RX_ADDRC 0x8063 +#define MII_LAN874X_PHY_MMD_MCFGR 0x8064 + +#define MII_LAN874X_PHY_PME1_SET (2 << 13) +#define MII_LAN874X_PHY_PME2_SET (2 << 11) +#define MII_LAN874X_PHY_PME_SELF_CLEAR BIT(9) +#define MII_LAN874X_PHY_WOL_PFDA_FR BIT(7) +#define MII_LAN874X_PHY_WOL_WUFR BIT(6) +#define MII_LAN874X_PHY_WOL_MPR BIT(5) +#define MII_LAN874X_PHY_WOL_BCAST_FR BIT(4) +#define MII_LAN874X_PHY_WOL_PFDAEN BIT(3) +#define MII_LAN874X_PHY_WOL_WUEN BIT(2) +#define MII_LAN874X_PHY_WOL_MPEN BIT(1) +#define MII_LAN874X_PHY_WOL_BCSTEN BIT(0) + +#define MII_LAN874X_PHY_WOL_FILTER_EN BIT(15) +#define MII_LAN874X_PHY_WOL_FILTER_MCASTTEN BIT(9) +#define MII_LAN874X_PHY_WOL_FILTER_BCSTEN BIT(8) + +#define MII_LAN874X_PHY_PME_SELF_CLEAR_DELAY 0x1000/* 81 milliseconds */ +#endif /* __LINUX_SMSCPHY_H__ */
net/ipv6/addrconf.c +1 -0
@@ -1879,6 +1879,7 @@ int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr,rcu_read_unlock ();return err; } +EXPORT_SYMBOL (ipv6_get_lladdr);static int ipv6_count_addresses (const struct inet6_dev *idev) {
Signature · 1 line
2.17.1
Jakub Kicinski
maintainerQuoted 10 lines · On Wed, 14 Jun 2023 17:15:50 -0700 [email protected] wrote:
Microchip LAN8740/LAN8742 PHYs support basic unicast, broadcast, and Magic Packet WoL. They have one pattern filter matching up to 128 bytes of frame data, which can be used to implement ARP or multicast WoL.
ARP WoL matches ARP request for IPv4 address of the net device using the PHY.
Multicast WoL matches IPv6 Neighbor Solicitation which is sent when somebody wants to talk to the net device using IPv6. This implementation may not be appropriate and can be changed by users later.
Quick look at lan743x and natsemi seems to indicate that WAKE_ARP means wake on _any_ arp, not arp directed to the local IPv4 addr.
Could you separate the changes to support other wake types out and post separately? We can merge that without much controversy. The ARP may need a discussion. My instinct is that since existing drivers interpret ARP as any ARP we should add a new type to the uAPI for local ARP.
Sorry for the long review delay.
Signature · 1 line
pw-bot: cr
Quoted 12 lines · On Wed, 14 Jun 2023 17:15:50 -0700 [email protected] wrote:
Quoted 10 lines
Microchip LAN8740/LAN8742 PHYs support basic unicast, broadcast, and Magic Packet WoL. They have one pattern filter matching up to 128 bytes of frame data, which can be used to implement ARP or multicast WoL.
ARP WoL matches ARP request for IPv4 address of the net device using the PHY.
Multicast WoL matches IPv6 Neighbor Solicitation which is sent when somebody wants to talk to the net device using IPv6. This implementation may not be appropriate and can be changed by users later.
Quoted 7 lines
Quick look at lan743x and natsemi seems to indicate that
WAKE_ARPmeans wake on _any_ arp, not arp directed to the local IPv4 addr.Could you separate the changes to support other wake types out and post separately? We can merge that without much controversy. The ARP may need a discussion. My instinct is that since existing drivers interpret ARP as any ARP we should add a new type to the uAPI for local ARP.
It seems getting IP and IPv6 addresses from PHY driver is not well supported or recommended, so a new patch just supporting generic ARP and multicast WoL will be submitted.