1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * NXP Wireless LAN device driver: ethtool 4 * 5 * Copyright 2011-2020 NXP 6 */ 7 8 #include "main.h" 9 10 static void mwifiex_ethtool_get_wol(struct net_device *dev, 11 struct ethtool_wolinfo *wol) 12 { 13 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 14 u32 conditions = le32_to_cpu(priv->adapter->hs_cfg.conditions); 15 16 wol->supported = WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY; 17 18 if (conditions == HS_CFG_COND_DEF) 19 return; 20 21 if (conditions & HS_CFG_COND_UNICAST_DATA) 22 wol->wolopts |= WAKE_UCAST; 23 if (conditions & HS_CFG_COND_MULTICAST_DATA) 24 wol->wolopts |= WAKE_MCAST; 25 if (conditions & HS_CFG_COND_BROADCAST_DATA) 26 wol->wolopts |= WAKE_BCAST; 27 if (conditions & HS_CFG_COND_MAC_EVENT) 28 wol->wolopts |= WAKE_PHY; 29 } 30 31 static int mwifiex_ethtool_set_wol(struct net_device *dev, 32 struct ethtool_wolinfo *wol) 33 { 34 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 35 u32 conditions = 0; 36 37 if (wol->wolopts & ~(WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY)) 38 return -EOPNOTSUPP; 39 40 if (wol->wolopts & WAKE_UCAST) 41 conditions |= HS_CFG_COND_UNICAST_DATA; 42 if (wol->wolopts & WAKE_MCAST) 43 conditions |= HS_CFG_COND_MULTICAST_DATA; 44 if (wol->wolopts & WAKE_BCAST) 45 conditions |= HS_CFG_COND_BROADCAST_DATA; 46 if (wol->wolopts & WAKE_PHY) 47 conditions |= HS_CFG_COND_MAC_EVENT; 48 if (wol->wolopts == 0) 49 conditions |= HS_CFG_COND_DEF; 50 priv->adapter->hs_cfg.conditions = cpu_to_le32(conditions); 51 52 return 0; 53 } 54 55 const struct ethtool_ops mwifiex_ethtool_ops = { 56 .get_wol = mwifiex_ethtool_get_wol, 57 .set_wol = mwifiex_ethtool_set_wol, 58 }; 59