dfs_pattern_detector.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. * @chirp: chirp detected in pulse
  40. */
  41. struct pulse_event {
  42. u64 ts;
  43. u16 freq;
  44. u8 width;
  45. u8 rssi;
  46. bool chirp;
  47. };
  48. /**
  49. * struct radar_detector_specs - detector specs for a radar pattern type
  50. * @type_id: pattern type, as defined by regulatory
  51. * @width_min: minimum radar pulse width in [us]
  52. * @width_max: maximum radar pulse width in [us]
  53. * @pri_min: minimum pulse repetition interval in [us] (including tolerance)
  54. * @pri_max: minimum pri in [us] (including tolerance)
  55. * @num_pri: maximum number of different pri for this type
  56. * @ppb: pulses per bursts for this type
  57. * @ppb_thresh: number of pulses required to trigger detection
  58. * @max_pri_tolerance: pulse time stamp tolerance on both sides [us]
  59. * @chirp: chirp required for the radar pattern
  60. */
  61. struct radar_detector_specs {
  62. u8 type_id;
  63. u8 width_min;
  64. u8 width_max;
  65. u16 pri_min;
  66. u16 pri_max;
  67. u8 num_pri;
  68. u8 ppb;
  69. u8 ppb_thresh;
  70. u8 max_pri_tolerance;
  71. bool chirp;
  72. };
  73. /**
  74. * struct dfs_pattern_detector - DFS pattern detector
  75. * @exit(): destructor
  76. * @set_dfs_domain(): set DFS domain, resets detector lines upon domain changes
  77. * @add_pulse(): add radar pulse to detector, returns true on detection
  78. * @region: active DFS region, NL80211_DFS_UNSET until set
  79. * @num_radar_types: number of different radar types
  80. * @last_pulse_ts: time stamp of last valid pulse in usecs
  81. * @radar_detector_specs: array of radar detection specs
  82. * @channel_detectors: list connecting channel_detector elements
  83. */
  84. struct dfs_pattern_detector {
  85. void (*exit)(struct dfs_pattern_detector *dpd);
  86. bool (*set_dfs_domain)(struct dfs_pattern_detector *dpd,
  87. enum nl80211_dfs_regions region);
  88. bool (*add_pulse)(struct dfs_pattern_detector *dpd,
  89. struct pulse_event *pe);
  90. struct ath_dfs_pool_stats (*get_stats)(struct dfs_pattern_detector *dpd);
  91. enum nl80211_dfs_regions region;
  92. u8 num_radar_types;
  93. u64 last_pulse_ts;
  94. /* needed for ath_dbg() */
  95. struct ath_common *common;
  96. const struct radar_detector_specs *radar_spec;
  97. struct list_head channel_detectors;
  98. };
  99. /**
  100. * dfs_pattern_detector_init() - constructor for pattern detector class
  101. * @param region: DFS domain to be used, can be NL80211_DFS_UNSET at creation
  102. * @return instance pointer on success, NULL otherwise
  103. */
  104. extern struct dfs_pattern_detector *
  105. dfs_pattern_detector_init(struct ath_common *common,
  106. enum nl80211_dfs_regions region);
  107. #endif /* DFS_PATTERN_DETECTOR_H */