dfs_pattern_detector.h 3.4 KB

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