dfs_pattern_detector.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2012 Neratec Solutions AG
  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. #ifndef DFS_PATTERN_DETECTOR_H
  17. #define DFS_PATTERN_DETECTOR_H
  18. #include <linux/types.h>
  19. #include <linux/list.h>
  20. #include <linux/nl80211.h>
  21. /**
  22. * struct ath_dfs_pool_stats - DFS Statistics for global pools
  23. */
  24. struct ath_dfs_pool_stats {
  25. u32 pool_reference;
  26. u32 pulse_allocated;
  27. u32 pulse_alloc_error;
  28. u32 pulse_used;
  29. u32 pseq_allocated;
  30. u32 pseq_alloc_error;
  31. u32 pseq_used;
  32. };
  33. /**
  34. * struct pulse_event - describing pulses reported by PHY
  35. * @ts: pulse time stamp in us
  36. * @freq: channel frequency in MHz
  37. * @width: pulse duration in us
  38. * @rssi: rssi of radar event
  39. */
  40. struct pulse_event {
  41. u64 ts;
  42. u16 freq;
  43. u8 width;
  44. u8 rssi;
  45. };
  46. /**
  47. * struct radar_detector_specs - detector specs for a radar pattern type
  48. * @type_id: pattern type, as defined by regulatory
  49. * @width_min: minimum radar pulse width in [us]
  50. * @width_max: maximum radar pulse width in [us]
  51. * @pri_min: minimum pulse repetition interval in [us] (including tolerance)
  52. * @pri_max: minimum pri in [us] (including tolerance)
  53. * @num_pri: maximum number of different pri for this type
  54. * @ppb: pulses per bursts for this type
  55. * @ppb_thresh: number of pulses required to trigger detection
  56. * @max_pri_tolerance: pulse time stamp tolerance on both sides [us]
  57. */
  58. struct radar_detector_specs {
  59. u8 type_id;
  60. u8 width_min;
  61. u8 width_max;
  62. u16 pri_min;
  63. u16 pri_max;
  64. u8 num_pri;
  65. u8 ppb;
  66. u8 ppb_thresh;
  67. u8 max_pri_tolerance;
  68. };
  69. /**
  70. * struct dfs_pattern_detector - DFS pattern detector
  71. * @exit(): destructor
  72. * @set_dfs_domain(): set DFS domain, resets detector lines upon domain changes
  73. * @add_pulse(): add radar pulse to detector, returns true on detection
  74. * @region: active DFS region, NL80211_DFS_UNSET until set
  75. * @num_radar_types: number of different radar types
  76. * @last_pulse_ts: time stamp of last valid pulse in usecs
  77. * @radar_detector_specs: array of radar detection specs
  78. * @channel_detectors: list connecting channel_detector elements
  79. */
  80. struct dfs_pattern_detector {
  81. void (*exit)(struct dfs_pattern_detector *dpd);
  82. bool (*set_dfs_domain)(struct dfs_pattern_detector *dpd,
  83. enum nl80211_dfs_regions region);
  84. bool (*add_pulse)(struct dfs_pattern_detector *dpd,
  85. struct pulse_event *pe);
  86. struct ath_dfs_pool_stats (*get_stats)(struct dfs_pattern_detector *dpd);
  87. enum nl80211_dfs_regions region;
  88. u8 num_radar_types;
  89. u64 last_pulse_ts;
  90. /* needed for ath_dbg() */
  91. struct ath_common *common;
  92. const struct radar_detector_specs *radar_spec;
  93. struct list_head channel_detectors;
  94. };
  95. /**
  96. * dfs_pattern_detector_init() - constructor for pattern detector class
  97. * @param region: DFS domain to be used, can be NL80211_DFS_UNSET at creation
  98. * @return instance pointer on success, NULL otherwise
  99. */
  100. extern struct dfs_pattern_detector *
  101. dfs_pattern_detector_init(struct ath_common *common,
  102. enum nl80211_dfs_regions region);
  103. #endif /* DFS_PATTERN_DETECTOR_H */