dfs_debug.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011 Neratec Solutions AG
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include <linux/debugfs.h>
  18. #include <linux/export.h>
  19. #include "ath9k.h"
  20. #include "dfs_debug.h"
  21. #define ATH9K_DFS_STAT(s, p) \
  22. len += snprintf(buf + len, size - len, "%28s : %10u\n", s, \
  23. sc->debug.stats.dfs_stats.p);
  24. static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
  25. size_t count, loff_t *ppos)
  26. {
  27. struct ath_softc *sc = file->private_data;
  28. struct ath9k_hw_version *hw_ver = &sc->sc_ah->hw_version;
  29. char *buf;
  30. unsigned int len = 0, size = 8000;
  31. ssize_t retval = 0;
  32. buf = kzalloc(size, GFP_KERNEL);
  33. if (buf == NULL)
  34. return -ENOMEM;
  35. len += snprintf(buf + len, size - len, "DFS support for "
  36. "macVersion = 0x%x, macRev = 0x%x: %s\n",
  37. hw_ver->macVersion, hw_ver->macRev,
  38. (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ?
  39. "enabled" : "disabled");
  40. ATH9K_DFS_STAT("DFS pulses detected ", pulses_detected);
  41. ATH9K_DFS_STAT("Datalen discards ", datalen_discards);
  42. ATH9K_DFS_STAT("RSSI discards ", rssi_discards);
  43. ATH9K_DFS_STAT("BW info discards ", bwinfo_discards);
  44. ATH9K_DFS_STAT("Primary channel pulses ", pri_phy_errors);
  45. ATH9K_DFS_STAT("Secondary channel pulses", ext_phy_errors);
  46. ATH9K_DFS_STAT("Dual channel pulses ", dc_phy_errors);
  47. if (len > size)
  48. len = size;
  49. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  50. kfree(buf);
  51. return retval;
  52. }
  53. static int ath9k_dfs_debugfs_open(struct inode *inode, struct file *file)
  54. {
  55. file->private_data = inode->i_private;
  56. return 0;
  57. }
  58. static const struct file_operations fops_dfs_stats = {
  59. .read = read_file_dfs,
  60. .open = ath9k_dfs_debugfs_open,
  61. .owner = THIS_MODULE,
  62. .llseek = default_llseek,
  63. };
  64. void ath9k_dfs_init_debug(struct ath_softc *sc)
  65. {
  66. debugfs_create_file("dfs_stats", S_IRUSR,
  67. sc->debug.debugfs_phy, sc, &fops_dfs_stats);
  68. }