ethtool.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2014 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/etherdevice.h>
  17. #include <linux/pci.h>
  18. #include <linux/rtnetlink.h>
  19. #include <net/cfg80211.h>
  20. #include "wil6210.h"
  21. static int wil_ethtoolops_begin(struct net_device *ndev)
  22. {
  23. struct wil6210_priv *wil = ndev_to_wil(ndev);
  24. mutex_lock(&wil->mutex);
  25. wil_dbg_misc(wil, "%s()\n", __func__);
  26. return 0;
  27. }
  28. static void wil_ethtoolops_complete(struct net_device *ndev)
  29. {
  30. struct wil6210_priv *wil = ndev_to_wil(ndev);
  31. wil_dbg_misc(wil, "%s()\n", __func__);
  32. mutex_unlock(&wil->mutex);
  33. }
  34. static int wil_ethtoolops_get_coalesce(struct net_device *ndev,
  35. struct ethtool_coalesce *cp)
  36. {
  37. struct wil6210_priv *wil = ndev_to_wil(ndev);
  38. u32 itr_en, itr_val = 0;
  39. wil_dbg_misc(wil, "%s()\n", __func__);
  40. itr_en = ioread32(wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_CRL));
  41. if (itr_en & BIT_DMA_ITR_CNT_CRL_EN)
  42. itr_val = ioread32(wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
  43. cp->rx_coalesce_usecs = itr_val;
  44. return 0;
  45. }
  46. static int wil_ethtoolops_set_coalesce(struct net_device *ndev,
  47. struct ethtool_coalesce *cp)
  48. {
  49. struct wil6210_priv *wil = ndev_to_wil(ndev);
  50. wil_dbg_misc(wil, "%s(%d usec)\n", __func__, cp->rx_coalesce_usecs);
  51. if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR) {
  52. wil_dbg_misc(wil, "No IRQ coalescing in monitor mode\n");
  53. return -EINVAL;
  54. }
  55. /* only @rx_coalesce_usecs supported, ignore
  56. * other parameters
  57. */
  58. if (cp->rx_coalesce_usecs > WIL6210_ITR_TRSH_MAX)
  59. goto out_bad;
  60. wil->itr_trsh = cp->rx_coalesce_usecs;
  61. wil_set_itr_trsh(wil);
  62. return 0;
  63. out_bad:
  64. wil_dbg_misc(wil, "Unsupported coalescing params. Raw command:\n");
  65. print_hex_dump_debug("DBG[MISC] coal ", DUMP_PREFIX_OFFSET, 16, 4,
  66. cp, sizeof(*cp), false);
  67. return -EINVAL;
  68. }
  69. static const struct ethtool_ops wil_ethtool_ops = {
  70. .begin = wil_ethtoolops_begin,
  71. .complete = wil_ethtoolops_complete,
  72. .get_drvinfo = cfg80211_get_drvinfo,
  73. .get_coalesce = wil_ethtoolops_get_coalesce,
  74. .set_coalesce = wil_ethtoolops_set_coalesce,
  75. };
  76. void wil_set_ethtoolops(struct net_device *ndev)
  77. {
  78. ndev->ethtool_ops = &wil_ethtool_ops;
  79. }