ethtool.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Marvell Wireless LAN device driver: ethtool
  3. *
  4. * Copyright (C) 2013-2014, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  17. * this warranty disclaimer.
  18. */
  19. #include "main.h"
  20. static void mwifiex_ethtool_get_wol(struct net_device *dev,
  21. struct ethtool_wolinfo *wol)
  22. {
  23. struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
  24. u32 conditions = le32_to_cpu(priv->adapter->hs_cfg.conditions);
  25. wol->supported = WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY;
  26. if (conditions == HS_CFG_COND_DEF)
  27. return;
  28. if (conditions & HS_CFG_COND_UNICAST_DATA)
  29. wol->wolopts |= WAKE_UCAST;
  30. if (conditions & HS_CFG_COND_MULTICAST_DATA)
  31. wol->wolopts |= WAKE_MCAST;
  32. if (conditions & HS_CFG_COND_BROADCAST_DATA)
  33. wol->wolopts |= WAKE_BCAST;
  34. if (conditions & HS_CFG_COND_MAC_EVENT)
  35. wol->wolopts |= WAKE_PHY;
  36. }
  37. static int mwifiex_ethtool_set_wol(struct net_device *dev,
  38. struct ethtool_wolinfo *wol)
  39. {
  40. struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
  41. u32 conditions = 0;
  42. if (wol->wolopts & ~(WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY))
  43. return -EOPNOTSUPP;
  44. if (wol->wolopts & WAKE_UCAST)
  45. conditions |= HS_CFG_COND_UNICAST_DATA;
  46. if (wol->wolopts & WAKE_MCAST)
  47. conditions |= HS_CFG_COND_MULTICAST_DATA;
  48. if (wol->wolopts & WAKE_BCAST)
  49. conditions |= HS_CFG_COND_BROADCAST_DATA;
  50. if (wol->wolopts & WAKE_PHY)
  51. conditions |= HS_CFG_COND_MAC_EVENT;
  52. if (wol->wolopts == 0)
  53. conditions |= HS_CFG_COND_DEF;
  54. priv->adapter->hs_cfg.conditions = cpu_to_le32(conditions);
  55. return 0;
  56. }
  57. const struct ethtool_ops mwifiex_ethtool_ops = {
  58. .get_wol = mwifiex_ethtool_get_wol,
  59. .set_wol = mwifiex_ethtool_set_wol,
  60. };