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