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